home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / mm-1_07.lha / mm-1.07 / tmac.m < prev    next >
Text File  |  1992-11-19  |  53KB  |  2,378 lines

  1. .\"    Version:
  2. .ds RE 1.07
  3. .ig
  4. Copyright (C) 1991 Free Software Foundation, Inc.
  5. mgm is written by J÷rgen HΣgg (jh@efd.lth.se)
  6.  
  7. mgm is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 1, or (at your option) any later
  10. version.
  11.  
  12. mgm is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file LICENSE.  If not, write to the Free Software
  19. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22. Almost complete. The letter format is not included.
  23. Maybe as a separate package.
  24. Should be better as time goes.
  25.  
  26. Please send bugreports with examples to jh@efd.lth.se.
  27.  
  28. Naming convention stolen from mgs.
  29. Local names    module*name
  30. Extern names    module@name
  31. Env.var        environ:name
  32. Index        array!index
  33. ..
  34. .warn
  35. .\" ####### init ######
  36. .\"    Contents level [0:7], contents saved if heading level <= Cl
  37. .nr Cl 2
  38. .\"    Eject page between LIST OF XXXX if Cp == 0
  39. .nr Cp 0
  40. .\"    Debugflag
  41. .if !r D .nr D 0
  42. .\"    Eject after floating display is output [0:1]
  43. .nr De 0
  44. .\"    Floating keep output [0;5]
  45. .nr Df 5
  46. .\"    space before and after display if == 1 [0:1]
  47. .nr Ds 1
  48. .\"    Eject page
  49. .nr Ej 0
  50. .\"    Eqation lable adjust 0=left, 1=right
  51. .nr Eq 0
  52. .\"    Em dash string
  53. .ds EM \-
  54. .\"    Footnote spacing
  55. .nr Fs 1
  56. .\"    H1-H7    heading counters
  57. .nr H1 0 1
  58. .nr H2 0 1
  59. .nr H3 0 1
  60. .nr H4 0 1
  61. .nr H5 0 1
  62. .nr H6 0 1
  63. .nr H7 0 1
  64. .\"    Heading break level [0:7]
  65. .nr Hb 2
  66. .\"    heading centering level, [0:7]
  67. .nr Hc 0
  68. .\"    header format
  69. .ds HF 2 2 2 2 2 2 2
  70. .\"    heading temp. indent [0:2]
  71. .\"    0 -> 0 indent, left margin
  72. .\"    1 -> indent to right , like .P 1
  73. .\"    2 -> indent to line up with text part of preceding heading
  74. .nr Hi 1
  75. .\"    header pointsize
  76. .ds HP 0 0 0 0 0 0 0
  77. .\"    heading space level [0:7]
  78. .nr Hs 2
  79. .\"    heading numbering type
  80. .\"    0 -> multiple (1.1.1 ...)
  81. .\"    1 -> single
  82. .nr Ht 0
  83. .\"    Unnumbered heading level
  84. .nr Hu 2
  85. .\"    hyphenation in body
  86. .\"    0 -> no hyphenation
  87. .\"    1 -> hyphenation 14 on
  88. .nr Hy 1
  89. .\"    text for toc, selfexplanatory. Look in the new variable section
  90. .ds Lf LIST OF FIGURES
  91. .nr Lf 1
  92. .ds Lt LIST OF TABLES
  93. .nr Lt 1
  94. .ds Lx LIST OF EXHIBITS
  95. .nr Lx 1
  96. .ds Le LIST OF EQUATIONS
  97. .nr Le 0
  98. .\"    List indent, used by .AL
  99. .nr Li 6
  100. .\"    List space, if listlevel > Ls then no spacing will occur around lists.
  101. .nr Ls 99
  102. .\"    Numbering style [0:5]
  103. .nr N 0
  104. .\"    numbered paragraphs
  105. .\"    0 == not numbered
  106. .\"    1 == numbered in first level headings.
  107. .nr Np 0
  108. .\"    Format of figure,table,exhibit,equation titles.
  109. .\"    0= ". ", 1=" - "
  110. .nr Of 0
  111. .\"    paragraph indent
  112. .nr Pi 5
  113. .\"    paragraph spacing
  114. .nr Ps 1
  115. .\"    paragraph type
  116. .\"    0 == left-justified
  117. .\"    1 == indented .P
  118. .\"    2 == indented .P except after .H, .DE or .LE.
  119. .nr Pt 0
  120. .\"    Reference title
  121. .ds Rp REFERENCES
  122. .\"    Display indent
  123. .nr Si 5
  124. .\"
  125. .ds Tm \(tm
  126. .\"
  127. .\"---------------------------------------------
  128. .\"    Internal global variables
  129. .\"
  130. .\" These two are for cover macro .MT
  131. .\" Change @langage in the national file.
  132. .ds @cur-lib /usr/local/lib/groff/tmac
  133. .\" .ds @language
  134. .\"    Current pointsize and vertical space, always in points.
  135. .nr @ps 10
  136. .nr @vs 12
  137. .\"    Page length
  138. .ie r L .nr @pl \n[L]
  139. .el .nr @pl 11i
  140. .\"    page width
  141. .ie r W .nr @ll \n[W]
  142. .el .nr @ll 6i
  143. .\"    page offset
  144. .ie r O .nr @po \n[O]
  145. .el .nr @po 1i
  146. .\"
  147. .\" cheating...
  148. .\".pl 100i
  149. .pl \n[@pl]u
  150. .ll \n[@ll]u
  151. .lt \n[@ll]u
  152. .po \n[@po]u
  153. .nr @cur-ll \n[@ll]
  154. .\"---------------------------------------------
  155. .\"    New variables
  156. .\"
  157. .\" Appendix name
  158. .ds App APPENDIX
  159. .\" print appendixheader, 0 == don't
  160. .nr Aph 1
  161. .\"
  162. .\" header prespace level. If level <= Hps, then two lines will be printed
  163. .\" before the header instead of one.
  164. .nr Hps 1
  165. .\"
  166. .\" These variables controls the number of lines preceding .H.
  167. .\" Hps1 is the number of lines when level > Hps
  168. .nr Hps1 0.5v
  169. .if n .nr Hps1 1v
  170. .\"
  171. .\" Hps2 is the number of lines when level >= Hps
  172. .nr Hps2 1v
  173. .if n .nr Hps2 2v
  174. .\"
  175. .\" flag for mkindex
  176. .if !r Idxf .nr Idxf 0
  177. .\"    Change these in the national configuration file
  178. .ds Lifg Figure
  179. .ds Litb TABLE
  180. .ds Liex Exhibit
  181. .ds Liec Equation
  182. .ds Licon CONTENTS
  183. .\"
  184. .\" Lsp controls the height of an empty line. Normally 0.5v
  185. .nr Lsp 0.5v
  186. .if n .nr Lsp 1v
  187. .ds MO1 January
  188. .ds MO2 February
  189. .ds MO3 March
  190. .ds MO4 April
  191. .ds MO5 May
  192. .ds MO6 June
  193. .ds MO7 July
  194. .ds MO8 August
  195. .ds MO9 September
  196. .ds MO10 October
  197. .ds MO11 November
  198. .ds MO12 December
  199. .\" for GETR
  200. .ds Qrf See chapter \\*[Qrfh], page \\*[Qrfp].
  201. .\"    test for mgm macro. This can be used if the text must test
  202. .\"    what macros is used.
  203. .nr .mgm 1
  204. .\"
  205. .\"---------------------------------------------
  206. .\" set local variables.
  207. .ie d @language .mso mm/\\*[@language]_locale
  208. .el .mso mm/locale
  209. .\"---------------------------------------------
  210. .if \n[D] .tm Groff mm, version \*[RE].
  211. .\" ####### module init ######
  212. .\"    reset all things
  213. .de init@reset
  214. .ie \\n[misc@adjust] 'ad
  215. .el 'na
  216. .ie \\n[Hy] 'hy 14
  217. .el 'nh
  218. 'in 0
  219. 'ti 0
  220. 'ps \\n[@ps]
  221. 'vs \\n[@vs]
  222. ..
  223. .de @error
  224. .tm ******************
  225. .tm ERROR:(\\n[.F]) input line \\n[.c]:\\$*
  226. .if \\n[D] .backtrace
  227. .tm ******************
  228. .ab
  229. ..
  230. .\" ####### module debug #################################
  231. .de debug
  232. .tm \\$1:\\n[.F]:\\n[c.] ll=\\n[.l] vs=\\n[.v] ps=\\n[.s],\\n[.ps] \
  233. in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
  234. ..
  235. .de debug-all
  236. .nr debug*n 1n
  237. .nr debug*m 1m
  238. .tm \\$1:\\n[.F]:\\n[c.] ll=\\n[.l] vs=\\n[.v] ps=\\n[.s] in=\\n[.i]\
  239.  ad=\\n[.j] fi=\\n[.u] pl=\\n[.p] page=\\n[%] .o=\\n[.o]
  240. .tm _______ .d=\\n[.d] .f=\\n[.f] .h=\\n[.h] .k=\\n[.k] .n=\\n[.n]\
  241.  .p=\\n[.p] .t=\\n[.t] .z=\\n[.z] nl=\\n[nl] dn=\\n[dn] n=\\n[debug*n]
  242. ..
  243. .\" ####### module par #################################
  244. .nr par@ind-flag 1            \" indent on following P if Pt=2
  245. .nr hd*last-pos -1
  246. .nr hd*last-hpos -1
  247. .nr par*number 0 1
  248. .af par*number 01
  249. .nr par*num-count 0 1
  250. .af par*num-count 01
  251. .\"    reset numbered paragraphs, arg1 = headerlevel
  252. .de par@reset-num
  253. .if \\$1<3 .nr par*num-count 0
  254. .if (\\$1=1)&(\\n[Np]=1) .nr par*number 0
  255. ..
  256. .\"------------
  257. .\" paragraph
  258. .de P
  259. .\"    skip P if previous heading
  260. .ie !((\\n[nl]=\\n[hd*last-pos]):(\\n[nl]=(\\n[hd*last-pos]-.5v))) \{\
  261. .    if \\n[D]>2 .tm Paragraph 
  262. .    par@doit \\$*
  263. .\}
  264. .el .if !(\\n[hd*last-hpos]=\\n[.k]) \{\
  265. .    if \\n[D]>2 .tm Paragraph 
  266. .    par@doit \\$*
  267. .\}
  268. ..
  269. .de par@doit
  270. .SP \\n[Ps]/2u
  271. .ie  \\n[.$] \{\
  272. .    if \\$1=1 .ti +\\n[Pi]n
  273. .\}
  274. .el \{\
  275. .    if \\n[Pt]=1 .ti +\\n[Pi]n
  276. .    if (\\n[Pt]=2)&\\n[par@ind-flag] .ti +\\n[Pi]n
  277. .\}
  278. .if \\n[Np] \{\
  279. \\n[H1].\\n+[par*number]\ \ \c
  280. .\" $$$ 'br
  281. .\}
  282. .nr par@ind-flag 1
  283. ..
  284. .\" ####### module line #######################################
  285. .de SP
  286. .br
  287. .if !r line*lp\\n[.z] .nr line*lp\\n[.z] 0
  288. .if !r line*ac\\n[.z] .nr line*ac\\n[.z] 0
  289. .ie \\n[.$] .nr line*temp (v;\\$1)
  290. .el .nr line*temp 1v
  291. .\"
  292. .ie \\n[line*lp\\n[.z]]=\\n[.d] \{\
  293. .    \" go here if no output since the last .SP
  294. .    nr line*output \\n[line*temp]-\\n[line*ac\\n[.z]]
  295. .    if \\n[line*output]<0 .nr line*output 0
  296. .    nr line*ac\\n[.z] +\\n[line*output]
  297. .\}
  298. .el \{\
  299. .    nr line*ac\\n[.z] \\n[line*temp]
  300. .    nr line*output \\n[line*temp]
  301. .    \" no extra space in the beginning of a page
  302. .    if (\\n[.d]<0):(\\n[pg*head-mark]=\\n[.d]) .nr line*output 0
  303. .\}
  304. .if \\n[line*output] .sp \\n[line*output]u
  305. .nr line*lp\\n[.z] \\n[.d]
  306. ..
  307. .\" ######## module misc ###############
  308. .nr misc@adjust 14
  309. .de SA
  310. .if \\n[.$] \{\
  311. .    if \\$1-1 .@error "SA: bad arg: \\$1"
  312. .    nr misc@adjust 0\\$1
  313. .\}
  314. .ie \\n[misc@adjust] 'ad
  315. .el 'na
  316. ..
  317. .\"-------------
  318. .\" switch environment, keep all important settings.
  319. .de misc@ev-keep
  320. .nr misc*ll \\n[.l]
  321. .ev \\$1
  322. .ll \\n[misc*ll]u
  323. .lt \\n[misc*ll]u
  324. ..
  325. .\"-------------
  326. .\" .misc@push stackname value
  327. .de misc@push
  328. .ie d misc*st-\\$1 .ds misc*st-\\$1 \\$2 \\*[misc*st-\\$1]
  329. .el .ds misc*st-\\$1 \\$2
  330. ..
  331. .\"-------------
  332. .\" .misc@pop stackname
  333. .\" value returned in the string misc*pop
  334. .de misc@pop
  335. .misc@pop-set misc*st-\\$1 \\*[misc*st-\\$1]
  336. ..
  337. .\"-------------
  338. .de misc@pop-set
  339. .ds misc*st-name \\$1
  340. .shift
  341. .if \\n[.$]<1 .@error "stack \\*[misc*st-name] empty"
  342. .ds misc*pop \\$1
  343. .shift
  344. .ds \\*[misc*st-name] \\$*
  345. ..
  346. .\"-------------
  347. .\" .misc@pop-nr stackname varname
  348. .de misc@pop-nr
  349. .misc@pop \\$1
  350. .nr \\$2 \\*[misc*pop]
  351. ..
  352. .\"-------------
  353. .\" .misc@pop-ds stackname varname
  354. .de misc@pop-ds
  355. .misc@pop \\$1
  356. .ds \\$2 \\*[misc*pop]
  357. ..
  358. .\"-----------
  359. .\" reset tabs
  360. .de TAB
  361. .ta T 5n
  362. ..
  363. .\"-------------
  364. .\" .PGFORM linelength [ pagelength [ pageoffset ] ]
  365. .de PGFORM
  366. .if !''\\$1' .nr @ll \\$1
  367. .if !''\\$2' .nr @pl \\$2
  368. .if !''\\$3' .nr @po \\$3
  369. .ll \\n[@ll]u
  370. .lt \\n[@ll]u
  371. .po \\n[@po]u
  372. .pl \\n[@pl]u
  373. .nr @cur-ll \\n[@ll]
  374. .in 0
  375. .pg@move-trap
  376. ..
  377. .\"-------------
  378. .\" .MOVE y [[x] linelength]
  379. .\" move to line y, indent to x
  380. .de MOVE
  381. .if !\\n[.$] .@error "MOVE y [x]: no arguments"
  382. .if \\n[nl]<0 \c
  383. .sp |(v;\\$1)
  384. .ie \\n[.$]>2 .nr pg*i (v;\\$3)
  385. .el \{\
  386. .    ie \\n[.$]>1 .nr pg*i (v;\\n[@ll]u-\\$2)
  387. .    el .nr pg*i (v;\\n[@ll]u)
  388. .\}
  389. .if !''\\$2' \{\
  390. .    po \\$2
  391. .    ll \\n[pg*i]u+\\n[@po]u
  392. .\}
  393. ..
  394. .\"-------------
  395. .de SM
  396. .if !\\n[.$] .@error "SM: no arguments"
  397. .if \\n[.$]=1 \s-1\\$1\s0
  398. .if \\n[.$]=2 \s-1\\$1\s0\\$2
  399. .if \\n[.$]=3 \\$1\s-1\\$2\s0\\$3
  400. ..
  401. .\"-------------
  402. .nr misc*S-ps \n[@ps]
  403. .nr misc*S-vs \n[@vs]
  404. .nr misc*S-ps1 \n[@ps]
  405. .nr misc*S-vs1 \n[@vs]
  406. .ds misc*a
  407. .ds misc*b
  408. .de S
  409. .ie !\\n[.$] \{\
  410. .    ds misc*a P
  411. .    ds misc*b P
  412. .\}
  413. .el \{\
  414. .    ie \\n[.$]=1 .ds misc*b D
  415. .    el \{\
  416. .        ie \w@\\$2@=0 .ds misc*b C
  417. .        el .ds misc*b \\$2
  418. .    \}
  419. .    ie \w@\\$1@=0 .ds misc*a C
  420. .    el .ds misc*a \\$1
  421. .\}
  422. .\" set point size
  423. .if !'\\*[misc*a]'C' \{\
  424. .    ie '\\*[misc*a]'P' .nr @ps \\n[misc*S-ps]
  425. .    el \{\
  426. .        ie '\\*[misc*a]'D' .nr @ps 10
  427. .        el .nr @ps \\*[misc*a]
  428. .    \}
  429. .\}
  430. .\" set vertical spacing
  431. .if !'\\*[misc*b]'C' \{\
  432. .    ie '\\*[misc*b]'P' .nr @vs \\n[misc*S-vs]
  433. .    el \{\
  434. .        ie '\\*[misc*b]'D' .nr @vs \\n[@ps]+2
  435. .        el .nr @vs \\*[misc*b]
  436. .    \}
  437. .\}
  438. 'ps \\n[@ps]
  439. 'vs \\n[@vs]
  440. .if \\n[D]>1 .tm point-size \\n[@ps] (\\n[.s]), vertical spacing \\n[@vs] (\\n[.v])
  441. .nr misc*S-ps \\n[misc*S-ps1]
  442. .nr misc*S-vs \\n[misc*S-vs1]
  443. .nr misc*S-ps1 \\n[@ps]
  444. .nr misc*S-vs1 \\n[@vs]
  445. ..
  446. .\"------------
  447. .de HC
  448. .ev 0
  449. .hc \\$1
  450. .ev
  451. .ev 1
  452. .hc \\$1
  453. .ev
  454. .ev 2
  455. .hc \\$1
  456. .ev
  457. ..
  458. .\"------------
  459. .de RD
  460. .di misc*rd
  461. 'fl
  462. .rd \\$1
  463. .br
  464. .di
  465. .ie !''\\$3' \{\
  466. .    di misc*rd2
  467. .    ds \\$3 "\\*[misc*rd]
  468. .    br
  469. .    di
  470. .\}
  471. .if !''\\$2' .rn misc*rd \\$2
  472. .rm misc*rd misc*rd2
  473. ..
  474. .\"------------
  475. .de VERBON
  476. .br
  477. .misc@ev-keep misc*verb-ev
  478. .nf
  479. .ft CR
  480. .ss 12
  481. .ta T 8u*\w@n@u
  482. ..
  483. .de VERBOFF
  484. .ev
  485. ..
  486. .\" ######## module acc #################
  487. .\"-----------
  488. .\" accents. These are copied from mgs, written by James Clark.
  489. .de acc@over-def
  490. .ds \\$1 \Z'\v'(u;\w'x'*0+\En[rst]-\En[.cht])'\
  491. \h'(u;-\En[skw]+(-\En[.w]-\w'\\$2'/2)+\En[.csk])'\\$2'
  492. ..
  493. .de acc@under-def
  494. .ds \\$1 \Z'\v'\En[.cdp]u'\h'(u;-\En[.w]-\w'\\$2'/2)'\\$2'
  495. ..
  496. .acc@over-def ` \`
  497. .acc@over-def ' \'
  498. .acc@over-def ^ ^
  499. .acc@over-def ~ ~
  500. .acc@over-def : \(ad
  501. .acc@over-def ; \(ad
  502. .acc@under-def , \(ac
  503. .\" ######## module uni #################
  504. .\" unimplemented macros
  505. .de OK
  506. .tm "OK: not implemented"
  507. ..
  508. .de PM
  509. .tm "PM: not implemented"
  510. ..
  511. .\" ######## module hd #################
  512. .\" support for usermacro
  513. .nr hd*htype 0
  514. .ds hd*mark
  515. .ds hd*suf-space
  516. .nr hd*need 0
  517. .aln ;0 hd*htype
  518. .als }0 hd*mark
  519. .als }2 hd*suf-space
  520. .aln ;3 hd*need
  521. .\"-------------
  522. .\" .hd@split varable index name val1 val2 ...
  523. .de hd@split
  524. .if \\$2>(\\n[.$]-3) .@error "\\$3 must have at least \\$2 values (\\*[\\$3]).
  525. .nr hd*sp-tmp \\$2+3
  526. .ds \\$1 \\$[\\n[hd*sp-tmp]]
  527. ..
  528. .de HU
  529. .H 0 "\\$1"
  530. ..
  531. .\"-------------
  532. .de H
  533. .nr hd*cur-bline \\n[nl]
  534. .br
  535. .ds@print-float 2\"    $$$ could be wrong...
  536. .\" terminate all lists
  537. .LC 0
  538. .init@reset
  539. .nr hd*level 0\\$1
  540. .nr hd*arg1 0\\$1
  541. .if !\\n[hd*level] .nr hd*level \\n[Hu]
  542. .\"    Check if it's time for new page. Only if text has
  543. .\"    appeared before.
  544. .if \\n[Ej]&(\\n[Ej]>=\\n[hd*level])&(\\n[hd*cur-bline]>=0) .pg@next-page
  545. .\"    clear lower counters
  546. .nr hd*i 1 1
  547. .while \\n+[hd*i]<8 .if \\n[hd*level]<\\n[hd*i] .nr H\\n[hd*i] 0 1
  548. .\"
  549. .\" increment current counter
  550. .nr H\\n[hd*level] +1
  551. .ie \\n[hd*level]<=\\n[Hps] .SP \\n[Hps2]u\"         pre-space
  552. .el .SP \\n[Hps1]u
  553. .\"
  554. .\" hd*mark is the text written to the left of the header.
  555. .ds hd*mark \\n[H1].
  556. .if \\n[hd*level]>1 .as hd*mark \\n[H2]
  557. .nr hd*i 2 1
  558. .while \\n+[hd*i]<8 .if \\n[hd*level]>(\\n[hd*i]-1) .as hd*mark .\\n[H\\n[hd*i]]
  559. .if \\n[Ht] .ds hd*mark \\n[H\\n[hd*level]].
  560. .\"
  561. .\" toc-mark is sent to the table of contents
  562. .ds hd*toc-mark \\*[hd*mark]
  563. .as hd*mark \ \ \"            add spaces between mark and heading
  564. .if !\\n[hd*arg1] \{\
  565. .    ds hd*mark\"        no mark for unnumbered
  566. .    ds hd*toc-mark
  567. .\}
  568. .\"
  569. .if \\n[D]>1 .tm At header \\*[hd*toc-mark] "\\$2"
  570. .nr hd*htype 0                \" hd*htype = check break and space
  571. .                    \" 0 = run-in, 1 = break only, 2 = space
  572. .if \\n[hd*level]<=\\n[Hb] .nr hd*htype 1
  573. .if \\n[hd*level]<=\\n[Hs] .nr hd*htype 2
  574. .                    \" two spaces if hd*htype == 0
  575. .ie (\\n[hd*htype]=0)&(\w@\\$2@) .ds hd*suf-space "  \"
  576. .el .ds hd*suf-space
  577. .nr hd*need 2v                \" hd*need = header need space
  578. .\"---------- user macro HX ------------
  579. .\" user exit macro to override numbering
  580. .if d HX .HX \\n[hd*level] \\n[hd*arg1] "\\$2\\$3"
  581. .par@reset-num \\n[hd*level]\"            reset numbered paragraph
  582. .di hd*div
  583. \\*[hd*mark]\\$2\\$3\\*[hd*suf-space]
  584. .br
  585. .di
  586. .rm hd*div
  587. .if \\n[hd*htype]<2 .nr hd*need +.5v \"    add some extra space
  588. .ne \\n[hd*need]u+\\n[dn]u+.5p  \"    this is the needed space for a header
  589. .\"---------- user macro HY ------------- 
  590. .\"    user macro to reset indents
  591. .if d HY .HY \\n[hd*level] \\n[hd*arg1] "\\$2\\$3"
  592. .if \\n[hd*htype] .na \"        no adjust if run-in
  593. .hd@split hd*font \\n[hd*level] HF \\*[HF]\"    get font for this level
  594. .ft \\*[hd*font]\"            set new font
  595. .nr hd*ps-save \\n[.ps]u
  596. .hd@split hd*new-ps \\n[hd*level] HP \\*[HP]\"    get point size
  597. .ie (\\*[hd*new-ps]=0):(\w@\\*[hd*new-ps]@=0) \{\
  598. .    if \\n[hd*htype] \{\
  599. .        if '\\*[hd*font]'3' .ps -1z
  600. .        if '\\*[hd*font]'B' .ps -1z
  601. .    \}
  602. .\}
  603. .el .ps \\*[hd*new-ps]z
  604. .nr hd*mark-size \w@\\*[hd*mark]@
  605. .if (\\n[hd*level]<=\\n[Hc])&\\n[hd*htype] .ce\" center if level<=Hc
  606. .\"
  607. .\"    finally, output the header
  608. \\*[hd*mark]\&\c
  609. .\"    and the rest of the header
  610. .ie \\n[hd*htype] \{\
  611. \\$2\\$3
  612. .    br
  613. .\}
  614. .el \\$2\\$3\\*[hd*suf-space]\&\c
  615. .ft 1
  616. .ps \\n[hd*ps-save]u
  617. .\"
  618. .\" table of contents
  619. .if (\\n[hd*level]<=\\n[Cl])&\w@\\$2@ \{\
  620. .    toc@save \\n[hd*level] "\\*[hd*toc-mark]" "\\$2" \\n[%]
  621. .\}
  622. .\"    set adjust to previous value
  623. .SA
  624. .\"    do break or space
  625. .if \\n[hd*htype] .br
  626. .if \\n[hd*htype]>1 .SP .5
  627. .if \\n[hd*htype] \{\
  628. .    \"    indent if Hi=1 and Pt=1
  629. .    if (\\n[Hi]=1)&(\\n[Pt]=1) .ti +\\n[Pi]n
  630. .    \"    indent size of mark if Hi=2
  631. .    if \\n[hd*htype]&(\\n[Hi]>1) .ti +\\n[hd*mark-size]u
  632. .\}
  633. .nr par@ind-flag 0            \" no indent on .P if Pt=2
  634. .\"
  635. .\"    check if it is time to reset footnotes
  636. .if (\\n[hd*level]=1)&\\n[ft*clear-at-header] .nr ft*nr 0 1
  637. .\"
  638. .\"    check if it is time to reset indexes
  639. .if (\\n[hd*level]=1)&(\\n[N]=5) \{\
  640. .    nr lix*fg-nr 0 1
  641. .    nr lix*tb-nr 0 1
  642. .    nr lix*ec-nr 0 1
  643. .    nr lix*ex-nr 0 1
  644. .\}
  645. .\"---------- user macro HZ ----------
  646. .if d HZ .HZ \\n[hd*level] \\n[hd*arg1] "\\$2\\$3"
  647. .nr hd*last-pos \\n[nl]
  648. .nr hd*last-hpos \\n[.k]
  649. .nr par@ind-flag 0
  650. ..
  651. .\"--------
  652. .de HM
  653. .nr hd*i 0 1
  654. .while \\n+[hd*i]<8 .af H\\n[hd*i] \\$[\\n[hd*i]] 1
  655. ..
  656. .\"########### module pg ####################
  657. .\" set end of text trap
  658. .wh 0 pg@header
  659. .em pg@end-of-text
  660. .\"
  661. .ds pg*header ''- % -''
  662. .ds pg*even-footer
  663. .ds pg*odd-footer
  664. .ds pg*even-header
  665. .ds pg*odd-header
  666. .ds pg*footer
  667. .\"
  668. .nr pg*top-margin 0
  669. .nr pg*foot-margin 0
  670. .nr pg*block-size 0
  671. .nr pg*footer-size 5\"             1v+footer+even/odd footer+2v
  672. .nr pg*header-size 7\"             3v+header+even/odd header+2v
  673. .nr pg*extra-footer-size 0
  674. .nr pg*extra-header-size 0
  675. .nr ft*note-size 0
  676. .nr pg*cur-column 0
  677. .nr pg*cols-per-page 1
  678. .nr pg*cur-po \n[@po]
  679. .nr pg*head-mark 0
  680. .\"
  681. .nr pg*ps \n[@ps]
  682. .nr pg*vs \n[@vs]
  683. .\" compatibility reasons. Why not use %??
  684. .aln P %
  685. .\"-------------------------
  686. .\" footer traps: set, enable and disable
  687. .de pg@set-new-trap
  688. .nr pg*foot-trap \\n[@pl]u-(\\n[pg*block-size]u+\\n[ft*note-size]u+\\n[pg*foot-margin]u+\\n[pg*footer-size]v+\\n[pg*extra-footer-size]u)
  689. .if \\n[D]>2 .tm pg*foot-trap \\n[@pl]u-(\\n[pg*block-size]u+\\n[ft*note-size]u+\\n[pg*foot-margin]u+\\n[pg*footer-size]v) = \\n[pg*foot-trap]
  690. .\" last-pos points to the position of the footer and bottom 
  691. .\" block below foot-notes.
  692. .nr pg*last-pos \\n[@pl]u-(\\n[pg*block-size]u+\\n[pg*foot-margin]u+\\n[pg*footer-size]v)
  693. ..
  694. .de pg@enable-trap
  695. .wh \\n[pg*foot-trap]u pg@footer
  696. .if \\n[D]>2 .tm pg@enable-trap .t=\\n[.t] nl=\\n[nl]
  697. ..
  698. .de pg@disable-trap
  699. .ch pg@footer
  700. ..
  701. .\" move to new trap (if changed).
  702. .de pg@move-trap
  703. .pg@disable-trap
  704. .pg@set-new-trap
  705. .pg@enable-trap
  706. ..
  707. .de pg@enable-top-trap
  708. .\" set trap for pageheader.
  709. .nr pg*top-enabled 1
  710. ..
  711. .de pg@disable-top-trap
  712. .\" remove trap for pageheader.
  713. .nr pg*top-enabled 0
  714. ..
  715. .\" no header on the next page
  716. .de PGNH
  717. .nr pg*top-enabled -1
  718. ..
  719. .\" set first trap for pagefooter
  720. .pg@enable-top-trap
  721. .pg@set-new-trap
  722. .pg@enable-trap
  723. .\"-------------------------
  724. .\" stop output and begin on next page. Fix footnotes and all that.
  725. .de pg@next-page
  726. .\".debug next-page
  727. .ne 999i        \" activate trap
  728. .\" .pg@footer
  729. ..
  730. .\"-------------------------
  731. .\" support for PX and TP
  732. .als }t pg*header
  733. .als }e pg*even-header
  734. .als }o pg*odd-header
  735. .\"------------------------------------------------------------
  736. .\" HEADER
  737. .de pg@header
  738. .if \\n[D]>1 .tm Page# \\n[%] (\\n[.F]:\\n[c.])
  739. .if \\n[Idxf] \{\
  740. .tl '<pagenr\ \\n[%]>'''
  741. .\}
  742. .if \\n[pg*top-enabled] \{\
  743. .    if \\n[pg*extra-header-size] 'sp \\n[pg*extra-header-size]u
  744. .    if \\n[pg*top-margin] 'sp \\n[pg*top-margin]u
  745. .    ev pg*tl-ev
  746. .    pg@set-env
  747. .    ie !d TP \{\
  748. '        sp 3
  749. .        lt \\n[@ll]u
  750. .        tl \\*[pg*header]
  751. .        ie o .tl \\*[pg*odd-header]
  752. .        el .tl \\*[pg*even-header]
  753. '        sp 2
  754. .    \}
  755. .    el .TP
  756. .    ev
  757. .    \" why no-space??
  758. .    if d PX \{\
  759. .        ns
  760. .        PX
  761. .        rs
  762. .    \}
  763. .    \" check for pending footnotes 
  764. .    ft@check-old
  765. .    \"
  766. .    \" back to normal text processing
  767. .    \" .pg@enable-trap
  768. .    \" mark for multicolumn
  769. .    nr pg*head-mark \\n[nl]u
  770. .    \" set multicolumn
  771. .    \" 
  772. .    pg@set-po
  773. .    \" print floating displays
  774. .    ds@print-float 4
  775. .    tbl@top-hook
  776. .    ns
  777. .\}
  778. .if \\n[pg*top-enabled]<0 .nr pg*top-enabled 1
  779. ..
  780. .\"---------------------------------------------------------
  781. .\" FOOTER
  782. .de pg@footer
  783. .pg@disable-trap
  784. .\".debug footer
  785. .tbl@bottom-hook
  786. .\" increment pageoffset for MC
  787. .\" move to the exact start of footer.
  788. 'sp |\\n[pg*foot-trap]u+1v
  789. .\"
  790. .if \\n[D]>3 .tm FOOTER after .sp
  791. .\" print footnotes
  792. .if d ft*div .ft@print
  793. .\"
  794. .pg@inc-po
  795. .if !\\n[pg*cur-column] .pg@print-footer
  796. .\" next column
  797. .pg@set-po
  798. .pg@enable-trap
  799. ..
  800. .\"-------------------------
  801. .de pg@print-footer
  802. .\" jump to the position just below the foot-notes.
  803. 'sp |\\n[pg*last-pos]u+1v
  804. .\" check if there are any bottom block
  805. .if d pg*block-div .pg@block
  806. .\"
  807. .\" print the footer and eject new page
  808. .ev pg*tl-ev
  809. .pg@set-env
  810. .lt \\n[@ll]u
  811. .ie o .tl \\*[pg*odd-footer]
  812. .el .tl \\*[pg*even-footer]
  813. .tl \\*[pg*footer]
  814. .ev
  815. .ie (\\n[ds*fnr]>=\\n[ds*o-fnr]):\\n[ft*exist] \{\
  816. .    ev ne
  817. '    bp
  818. .    ev
  819. .\}
  820. .el 'bp
  821. ..
  822. .\"-------------------------
  823. .\"
  824. .\" Initialize the title environment
  825. .de pg@set-env
  826. 'na
  827. 'nh
  828. 'in 0
  829. 'ti 0
  830. 'ps \\n[pg*ps]
  831. 'vs \\n[pg*vs]
  832. ..
  833. .\"-------------------------
  834. .de PH
  835. .ds pg*header "\\$1
  836. .pg@set-new-size
  837. ..
  838. .de PF
  839. .ds pg*footer "\\$1
  840. .pg@set-new-size
  841. ..
  842. .de OH
  843. .ds pg*odd-header "\\$1
  844. .pg@set-new-size
  845. ..
  846. .de EH
  847. .ds pg*even-header "\\$1
  848. .pg@set-new-size
  849. ..
  850. .de OF
  851. .ds pg*odd-footer "\\$1
  852. .pg@set-new-size
  853. ..
  854. .de EF
  855. .ds pg*even-footer "\\$1
  856. .pg@set-new-size
  857. ..
  858. .de pg@clear-hd
  859. .ds pg*even-header
  860. .ds pg*odd-header
  861. .ds pg*header
  862. ..
  863. .de pg@clear-ft
  864. .ds pg*even-footer
  865. .ds pg*odd-footer
  866. .ds pg*footer
  867. ..
  868. .de pg@set-new-size
  869. .nr pg*ps \\n[@ps]
  870. .nr pg*vs \\n[@vs]
  871. .pg@move-trap
  872. ..
  873. .\"-------------------------
  874. .\" end of page processing
  875. .de pg@footnotes
  876. .\".debug footnotes
  877. .\" output footnotes. set trap for block
  878. .\"
  879. ..
  880. .\"-------------------------
  881. .\" print bottom block
  882. .de pg@block
  883. .ev pg*block-ev
  884. 'nf
  885. 'in 0
  886. .ll 100i
  887. .pg*block-div
  888. .br
  889. .ev
  890. ..
  891. .\"-------------------------
  892. .\" define bottom block
  893. .de BS
  894. .misc@ev-keep pg*block-ev
  895. .init@reset
  896. .br
  897. .di pg*block-div
  898. ..
  899. .\"-------------------------
  900. .de BE
  901. .br
  902. .di
  903. .nr pg*block-size \\n[dn]u
  904. .ev
  905. .pg@move-trap
  906. ..
  907. .\"-------------------------
  908. .\" print out all pending text
  909. .de pg@end-of-text
  910. .\" non-empty environment
  911. .misc@ev-keep ne
  912. .init@reset
  913. \c
  914. .ds@print-float 3
  915. .ev
  916. .if d ref*div .RP
  917. ..
  918. .\"-------------------------
  919. .\" set top and bottom margins 
  920. .de VM
  921. .if \\n[.$]=0 \{\
  922. .    nr pg*extra-footer-size 0
  923. .    nr pg*extra-header-size 0
  924. .\}
  925. .if \\n[.$]>0 .nr pg*extra-header-size (v;\\$1)
  926. .if \\n[.$]>1 .nr pg*extra-footer-size (v;\\$2)
  927. .if \\n[D]>2 \{\
  928. .    tm extra top \\n[pg*extra-footer-size]
  929. .    tm extra bottom \\n[pg*extra-header-size]
  930. .\}
  931. .pg@move-trap
  932. ..
  933. .\"---------------------
  934. .\" multicolumn output. 
  935. .de pg@set-po
  936. .if \\n[pg*cols-per-page]>1 \{\
  937. .    ll \\n[pg*column-size]u
  938. .\}
  939. ..
  940. .de pg@inc-po
  941. .if \\n[pg*cols-per-page]>1 \{\
  942. .    ie \\n+[pg*cur-column]>=\\n[pg*cols-per-page] \{\
  943. .        nr pg*cur-column 0 1
  944. .        nr pg*cur-po \\n[@po]u
  945. .        po \\n[@po]u
  946. .        ll \\n[@ll]u
  947. .    \}
  948. .    el \{\
  949. .        nr pg*cur-po +(\\n[pg*column-size]u+\\n[pg*column-sep]u)
  950. .        po \\n[pg*cur-po]u
  951. '        sp |\\n[pg*head-mark]u
  952. .    \}
  953. .\}
  954. ..
  955. .de 1C
  956. .br
  957. .if \\n[pg*cols-per-page]<=1 .@error "1C: multicolumn mode not active"
  958. .nr pg*cols-per-page 1
  959. .nr pg*column-sep 0
  960. .nr pg*column-size \\n[@ll]
  961. .nr pg*cur-column 0 1
  962. .nr pg*cur-po \\n[@po]u
  963. .PGFORM
  964. .\".pg@next-page
  965. .SK
  966. ..
  967. .de 2C
  968. .br
  969. .nr pg*head-mark \\n[nl]u
  970. .if \\n[pg*cols-per-page]>1 .@error "2C: multicolumn mode already active"
  971. .nr pg*cols-per-page 2
  972. .nr pg*column-sep \\n[@ll]/15
  973. .nr pg*column-size (\\n[@ll]u*7)/15
  974. .nr pg*cur-column 0 1
  975. .nr pg*cur-po \\n[@po]u
  976. .ll \\n[pg*column-size]u
  977. .lt \\n[pg*column-size]u
  978. ..
  979. .\" MC column-size [ column-separation ]
  980. .de MC
  981. .br
  982. .nr pg*head-mark \\n[nl]u
  983. .if \\n[pg*cols-per-page]>1 .@error "MC: multicolumn mode already active"
  984. .ie ''\\$1' .nr pg*column-size \\n[.l]
  985. .el .nr pg*column-size (n;\\$1)
  986. .ie ''\\$2' .nr pg*column-sep \\n[pg*column-size]/15
  987. .el .nr pg*column-sep (n;\\$2)
  988. .\"
  989. .nr pg*cols-per-page (u;\\n[.l]/(\\n[pg*column-size]+\\n[pg*column-sep]+1))
  990. .nr pg*cur-column 0 1
  991. .nr pg*cur-po \\n[@po]u
  992. .ll \\n[pg*column-size]u
  993. .lt \\n[pg*column-size]u
  994. ..
  995. .\" begin a new column
  996. .de NCOL
  997. .br
  998. .pg@footer
  999. ..
  1000. .\" skip pages
  1001. .de SK
  1002. .br
  1003. .bp
  1004. .nr pg*i 0 1
  1005. .while \\n+[pg*i]<=(0\\$1) .bp
  1006. ..
  1007. .\"-----------
  1008. .de OP
  1009. .br
  1010. .ie o .if !\\n[pg*head-mark]=\\n[nl] \{\
  1011. .    bp +1
  1012. .    bp +1
  1013. .\}
  1014. .el .bp
  1015. ..
  1016. .\"########### module footnotes ###################
  1017. .nr ft*note-size 0
  1018. .nr ft*busy 0
  1019. .nr ft*nr 0 1
  1020. .nr ft*wide 0
  1021. .nr ft*hyphen 0\"    hyphenation value
  1022. .nr ft*adjust 1\"    >0 if adjust true
  1023. .nr ft*indent 1\"    >0 if text indent true (not imp. $$$)
  1024. .nr ft*just 0\"    0=left justification, 1=right (not imp. $$$)
  1025. .nr ft*exist 0\"    not zero if there are any footnotes to be printed
  1026. .nr ft*clear-at-header 0\" >0 if footnotes should be reset at first level head.
  1027. .\"
  1028. .ds F \v'-.4m'\s-3\\n+[ft*nr]\s0\v'.4m'
  1029. .\"
  1030. .\"-----------------
  1031. .\" init footnote environment
  1032. .de ft@init
  1033. .\" indentcontrol not implemented $$$
  1034. .\" label justification not implemented $$$
  1035. 'in 0
  1036. 'fi
  1037. .ie \\n[ft*adjust] 'ad
  1038. .el 'na
  1039. .ie \\n[ft*hyphen] 'hy 14
  1040. .el 'hy 0
  1041. .ll \\n[@cur-ll]u
  1042. .lt \\n[@cur-ll]u
  1043. .ps (\\n[@ps]-2)
  1044. .vs (\\n[@vs]-1)
  1045. ..
  1046. .\"-----------------
  1047. .\" set footnote format
  1048. .\" no support for two column processing (yet). $$$
  1049. .de FD
  1050. .if \\n[.$]=0 .@error "FD: bad arg \\$1"
  1051. .ie \\$1>11 .nr ft*format 0
  1052. .el .nr ft*format \\$1
  1053. .\"
  1054. .ie \\n[.$]=2 .nr ft*clear-at-header 1
  1055. .el .nr ft*clear-at-header 0
  1056. .\"
  1057. .nr ft*hyphen (\\n[ft*format]%2)*14
  1058. .nr ft*format \\n[ft*format]/2
  1059. .\"
  1060. .nr ft*adjust 1-(\\n[ft*format]%2)
  1061. .nr ft*format \\n[ft*format]/2
  1062. .\"
  1063. .nr ft*indent 1-(\\n[ft*format]%2)
  1064. .nr ft*format \\n[ft*format]/2
  1065. .\"
  1066. .nr ft*just \\n[ft*format]%2
  1067. ..
  1068. .\"---------------
  1069. .\" Footnote and display width control $$$
  1070. .de WC
  1071. .nr ft*i 0 1
  1072. .while \\n+[ft*i]<=\\n[.$] \{\
  1073. .    ds ft*x \\$[\\n[ft*i]]
  1074. .    if '\\*[ft*x]'N' \{\
  1075. .        nr ft*wide 0
  1076. .        nr ft*first-fn 0
  1077. .        nr ds*wide 0
  1078. .        nr ds*float-break 1
  1079. .    \}
  1080. .    if '\\*[ft*x]'-WF' .nr ft*wide 0
  1081. .    if '\\*[ft*x]'WF' .nr ft*wide 1
  1082. .    if '\\*[ft*x]'-FF' .nr ft*first-fn 0
  1083. .    if '\\*[ft*x]'FF' .nr ft*first-fn 1
  1084. .    if '\\*[ft*x]'-WD' .nr ds*wide 0
  1085. .    if '\\*[ft*x]'WD' .nr ds*wide 1
  1086. .    if '\\*[ft*x]'-FB' .nr ds*float-break 0
  1087. .    if '\\*[ft*x]'FB' .nr ds*float-break 1
  1088. .\}
  1089. ..
  1090. .\"-----------------
  1091. .\" begin footnote
  1092. .de FS
  1093. .if \\n[ft*busy] .@error "FS: missing FE"
  1094. .nr ft*busy 1
  1095. .ev ft*ev
  1096. .ft@init
  1097. .if !\\n[ft*wide] .pg@set-po
  1098. .if !d ft*div .ft@init-footnote
  1099. .di ft*tmp-div
  1100. .nr ft*space \\n[Fs]v/2u
  1101. .sp \\n[ft*space]u
  1102. .\" print mark
  1103. .ie \\n[.$] .ds ft*mark \\$1
  1104. .el .ds ft*mark \\n[ft*nr].
  1105. \\*[ft*mark]
  1106. .in +.75c
  1107. .sp -1
  1108. .nr ft*exist 1
  1109. ..
  1110. .\"-----------------
  1111. .\" init footnote diversion
  1112. .de ft@init-footnote
  1113. .di ft*div
  1114. \l'20n'
  1115. .br
  1116. .di
  1117. .nr ft*note-size \\n[dn]
  1118. ..
  1119. .\"-----------------
  1120. .\" end footnote
  1121. .de FE
  1122. .nr ft*busy 0
  1123. .br
  1124. .di
  1125. 'in 0
  1126. 'nf
  1127. .if \\n[@pl]u<\\n[dn]u .@error "FE: too big footnote"
  1128. .ie (\\n[pg*foot-trap]u-\\n[.d]u)<\\n[dn]u \{\
  1129. .    da ft*next-div
  1130. .    ft*tmp-div
  1131. .    br
  1132. .    di
  1133. .\}
  1134. .el \{\
  1135. .    da ft*div
  1136. .    ft*tmp-div
  1137. .    di
  1138. .    nr ft*note-size +\\n[dn]
  1139. .\}
  1140. .rm ft*tmp-div
  1141. .ev
  1142. .pg@move-trap
  1143. ..
  1144. .\"-----------------
  1145. .\" print footnotes, see pg@footer
  1146. .de ft@print
  1147. .ev ft*print-ev
  1148. 'nf
  1149. 'in 0
  1150. .ll 100i
  1151. .ft*div
  1152. .br
  1153. .ev
  1154. .rm ft*div
  1155. .nr ft*note-size 0
  1156. .pg@move-trap
  1157. ..
  1158. .\"-----------------
  1159. .\" check if any pending footnotes, see pg@header
  1160. .de ft@check-old
  1161. .if d ft*next-div \{\
  1162. .    ev ft*ev
  1163. .    ft@init
  1164. .    ft@init-footnote
  1165. .    nf
  1166. .    in 0
  1167. .    da ft*div
  1168. .    ft*next-div
  1169. .    di
  1170. .    nr ft*note-size +\\n[dn]
  1171. .    rm ft*next-div
  1172. .    ev
  1173. .    nr ft*exist 0
  1174. .    pg@move-trap
  1175. .\}
  1176. ..
  1177. .\"########### module display ###################
  1178. .nr ds*wide 0\"        >0 if wide displays wanted
  1179. .nr ds*fnr 0 1\"    floating display counter
  1180. .nr ds*o-fnr 1\"    floating display counter, already printed
  1181. .nr ds*snr 0 1\"    static display counter
  1182. .nr ds*lvl 0 1\"    display level
  1183. .nr ds*float-busy 0\"    >0 if printing float
  1184. .nr ds*ffloat 0\"    >0 if DF, 0 if DS
  1185. .\" static display start
  1186. .\" nested DS/DE is allowed. No limit on depth.
  1187. .de DS
  1188. .br
  1189. .ds@start 0 DS \\$@
  1190. ..
  1191. .\" floating display start
  1192. .\" nested DF/DE is not allowed.
  1193. .de DF
  1194. .if \\n[ds*lvl] .@error "DF:nested floating is not allowed. Use DS."
  1195. .ds@start 1 DF \\$@
  1196. ..
  1197. .\"---------------
  1198. .nr ds*format 0\"    dummy value for .En/.EQ
  1199. .nr ds*format! 0\"    no indent
  1200. .nr ds*format!0 0\"    no indent
  1201. .nr ds*format!L 0\"    no indent
  1202. .nr ds*format!I 1\"    indent
  1203. .nr ds*format!1 1\"    indent
  1204. .nr ds*format!C 2\"    center each line
  1205. .nr ds*format!2 2\"    center each line
  1206. .nr ds*format!CB 3\"    center as block
  1207. .nr ds*format!3 3\"    center as block
  1208. .nr ds*format!R 4\"    right justify each line
  1209. .nr ds*format!4 4\"    right justify each line
  1210. .nr ds*format!RB 5\"    right justify as block
  1211. .nr ds*format!5 5\"    right justify as block
  1212. .\"---------------
  1213. .nr ds*fill! 0\"    no fill
  1214. .nr ds*fill!N 0\"    no fill
  1215. .nr ds*fill!0 0\"    no fill
  1216. .nr ds*fill!F 1\"    fill on
  1217. .nr ds*fill!1 1\"    fill on
  1218. .\"---------------
  1219. .de ds@start
  1220. .nr ds*ffloat \\$1
  1221. .ds ds*type \\$2
  1222. .shift 2
  1223. .nr ds*lvl +1
  1224. .\" get format of the display
  1225. .ie \\n[.$] \{\
  1226. .    ie r ds*format!\\$1 .nr ds*format \\n[ds*format!\\$1]
  1227. .    el .@error "\\*[ds*type]:wrong format:\\$1"
  1228. .\}
  1229. .el .nr ds*format 0
  1230. .\" fill or not to fill, that is the...
  1231. .nr ds*fill 0
  1232. .ie \\n[.$]>1 \{\
  1233. .    ie r ds*fill!\\$2 .nr ds*fill \\n[ds*fill!\\$2]
  1234. .    el .@error "\\*[ds*type]:wrong fill:\\$2"
  1235. .\}
  1236. .nr ds*rindent 0
  1237. .if \\n[.$]>2 .nr ds*rindent \\$3
  1238. .\"
  1239. .\"
  1240. .nr ds*old-ll \\n[.l]
  1241. .misc@push ds-ll \\n[.l]
  1242. .misc@push ds-form \\n[ds*format]
  1243. .misc@push ds-ffloat \\n[ds*ffloat]
  1244. .nr ds*i \\n[.i]
  1245. .nr ds*ftmp \\n[.f]
  1246. .misc@ev-keep ds*ev!\\n+[ds*snr]
  1247. .ft \\n[ds*ftmp]
  1248. .\"
  1249. .init@reset
  1250. 'in \\n[ds*i]u
  1251. .di ds*div!\\n[ds*snr]
  1252. .\"
  1253. .ll \\n[ds*old-ll]u
  1254. .lt \\n[ds*old-ll]u
  1255. .if \\n[ds*rindent] \{\
  1256. .    ll -\\n[ds*rindent]n
  1257. .    lt -\\n[ds*rindent]n
  1258. .\}
  1259. .if \\n[ds*wide] \{\
  1260. .    ll \\n[@ll]u
  1261. .    lt \\n[@ll]u
  1262. .\}
  1263. .\"
  1264. .ie \\n[ds*fill] 'fi
  1265. .el 'nf
  1266. .\"
  1267. .if \\n[ds*format]=1 \{\
  1268. .    ll -\\n[Si]n
  1269. .    lt -\\n[Si]n
  1270. '    in +\\n[Si]n
  1271. .\}
  1272. .if (\\n[ds*format]=3):(\\n[ds*format]=5) 'in 0
  1273. ..
  1274. .\"---------------
  1275. .de DE
  1276. .if \\n-[ds*lvl]<0 .@error "DE: no corresponding DS or DF"
  1277. .br
  1278. .if \\n[ds*ffloat] .SP \\n[Lsp]u
  1279. .di
  1280. .nr ds*width \\n[dl]
  1281. .nr ds*height \\n[dn]
  1282. .misc@pop-nr ds-ll ds*old-ll
  1283. .misc@pop-nr ds-form ds*format
  1284. .misc@pop-nr ds-ffloat ds*ffloat
  1285. .if (\\n[ds*format]>=2)&(\\n[ds*width]>\\n[ds*old-ll]) \{\
  1286. .    @error "DE: display too wide for current line-length"
  1287. .\}
  1288. .\" prepare copy to floating display
  1289. .if \\n[ds*ffloat] .di ds*fdiv!\\n+[ds*fnr]
  1290. .\"
  1291. 'in 0
  1292. 'nf
  1293. .if \\n[ds*format]=2 'ce 9999
  1294. .if \\n[ds*format]=3 'in (u;(\\n[ds*old-ll]-\\n[ds*width])/2)
  1295. .if \\n[ds*format]=4 'rj 9999
  1296. .if \\n[ds*format]=5 'in (u;\\n[ds*old-ll]-\\n[ds*width])
  1297. .\"
  1298. .ie !\\n[ds*ffloat] \{\
  1299. .    \"
  1300. .    \"    Print static display
  1301. .    \"    Eject page if display will fit one page and
  1302. .    \"    there are less than half of the page left.
  1303. .    nr ds*i \\n[pg*foot-trap]-\\n[pg*header-size]v-\\n[pg*extra-header-size]v
  1304. .    if (\\n[ds*height]>\\n[ds*i])&(\\n[.t]<(\\n[ds*i]/2)) \{\
  1305. .        ne \\n[.t]u+1v
  1306. .    \}
  1307. .    if (\\n[ds*height]<\\n[ds*i])&(\\n[.t]<(\\n[ds*height])) \{\
  1308. .        ne \\n[.t]u+1v
  1309. .    \}
  1310. .    if \\n[Ds] .SP \\n[Lsp]u
  1311. .\}
  1312. .el .SP \\n[Lsp]u
  1313. .ds*div!\\n[ds*snr]
  1314. .ie !\\n[ds*ffloat] .if \\n[Ds] .SP \\n[Lsp]u
  1315. .el \{\
  1316. .    SP \\n[Lsp]u
  1317. .    di
  1318. .\}
  1319. .if \\n[ds*format]=2 'ce 0
  1320. .if \\n[ds*format]=4 'rj 0
  1321. .rm ds*div!\\n[ds*snr]
  1322. .nr ds*snr -1
  1323. .nr par@ind-flag 0
  1324. .\"        move div to the floating display list
  1325. .ev
  1326. .if \\n[ds*ffloat] \{\
  1327. .    nr ds*fsize!\\n[ds*fnr] \\n[dn]
  1328. .    \" print float if queue is empty and the display fits into
  1329. .    \" the current page
  1330. .    if (\\n[ds*fnr]>\\n[ds*o-fnr])&(\\n[ds*height]<\\n[.t]) \{\
  1331. .        ds@print-float 1
  1332. .    \}
  1333. .\}
  1334. ..
  1335. .\"---------------
  1336. .\" print according to Df and De.
  1337. .\" .ds@print-float type
  1338. .\"    type    called from
  1339. .\"    1    .DE
  1340. .\"    2    end of section
  1341. .\"    3    end of document
  1342. .\"    4    beginning of new page
  1343. .\"
  1344. .de ds@print-float
  1345. .if \\n[Df]>5 .@error "Df=\\n[Df], max value is 5"
  1346. .if !\\n[ds*float-busy] \{\
  1347. .    nr ds*float-busy 1
  1348. .\" at .DE
  1349. .    if (\\$1=1)&((\\n[Df]%2)=1) \{\
  1350. .        if \\n[.t]>\\n[ds*fsize!\\n[ds*fnr]] \{\
  1351. .            \" Df = 1,3 or 5
  1352. .            ds@print-one-float
  1353. .        \}
  1354. .    \}
  1355. .\" print all if Df<2 and end of section
  1356. .    if (\\$1=2)&(\\n[Df]<2) .ds@print-all-floats
  1357. .\" print all if end of document. Where should they go instead?
  1358. .    if \\$1=3 .ds@print-all-floats
  1359. .\" new page
  1360. .    if (\\$1=4)&(\\n[Df]>1) \{\
  1361. .        if \\n[Df]=2 .ds@print-one-float
  1362. .        if \\n[Df]=3 .ds@print-one-float
  1363. .        if \\n[Df]>3 \{\
  1364. .            ie \\n[De] .ds@print-all-floats
  1365. .            el .ds@print-this-page
  1366. .        \}
  1367. .    \}
  1368. .    nr ds*float-busy 0
  1369. .\}
  1370. ..
  1371. .\"---------------
  1372. .\" print a floating diversion
  1373. .de ds@output-div
  1374. .ev ds*fev
  1375. .in 0
  1376. .nf
  1377. .ds*fdiv!\\n[ds*o-fnr]
  1378. .ev
  1379. .rm ds*fdiv!\\n[ds*o-fnr]
  1380. .rm ds*fsize!\\n[ds*o-fnr]
  1381. .rm ds*fformat!\\n[ds*o-fnr]
  1382. .nr ds*o-fnr +1
  1383. ..
  1384. .\"---------------
  1385. .\" print one floating display if there is one.
  1386. .de ds@print-one-float
  1387. .if \\n[ds*o-fnr]<=\\n[ds*fnr] \{\
  1388. .    if \\n[.t]<\\n[ds*fsize!\\n[ds*o-fnr]] .pg@next-page
  1389. .    ds@output-div
  1390. .    if \\n[De] .pg@next-page
  1391. .\}
  1392. ..
  1393. .\"---------------
  1394. .\" print all queued floats.
  1395. .\" if De>0 do a page eject between the floats.
  1396. .de ds@print-all-floats
  1397. .while \\n[ds*o-fnr]<=\\n[ds*fnr] \{\
  1398. .    if \\n[.t]<\\n[ds*fsize!\\n[ds*o-fnr]] .pg@next-page
  1399. .    ds@output-div
  1400. .    if \\n[De] .pg@next-page
  1401. .\}
  1402. ..
  1403. .\"---------------
  1404. .\" print as many floats as will fit on the current page
  1405. .de ds@print-this-page
  1406. .while \\n[ds*o-fnr]<=\\n[ds*fnr] \{\
  1407. .    if \\n[.t]<\\n[ds*fsize!\\n[ds*o-fnr]] .break
  1408. .    ds@output-div
  1409. .\}
  1410. ..
  1411. .\"########### module list ###################
  1412. .\" .LI text-indent mark-indent pad type [mark [LI-space [LB-space] ] ]
  1413. .\"
  1414. .nr li*tind 0
  1415. .nr li*mind 0
  1416. .nr li*pad 0
  1417. .nr li*type 0
  1418. .ds li*mark 0
  1419. .nr li*li-spc 0
  1420. .nr li*lvl 0 1
  1421. .nr li*cur-vpos 0
  1422. .\"--------------------------
  1423. .\"    the major list-begin macro.
  1424. .\"    If type == -1 a 'break' will occur.
  1425. .de LB
  1426. .if \\n[.$]<4 .@error "LB: not enough arguments, min 4"
  1427. .misc@push cind \\n[.i]
  1428. .misc@push tind \\n[li*tind]
  1429. .misc@push mind \\n[li*mind]
  1430. .misc@push pad \\n[li*pad]
  1431. .misc@push type \\n[li*type]
  1432. .misc@push li-spc \\n[li*li-spc]
  1433. .ds li*mark-list!\\n[li*lvl] \\*[li*mark]
  1434. .nr li*lvl +1
  1435. .\"
  1436. .nr li*tind (n;0\\$1)\"            text-indent
  1437. .nr li*mind (n;0\\$2)\"            mark-indent
  1438. .nr li*pad (n;0\\$3)\"            pad
  1439. .nr li*type 0\\$4\"            type
  1440. .ds li*mark \\$5\"            mark
  1441. .ie !'\\$6'' .nr li*li-spc \\$6\"    LI-space
  1442. .el .nr li*li-spc 1
  1443. .ie !'\\$7'' .nr li*lb-spc \\$6\"    LB-space
  1444. .el .nr li*lb-spc 0
  1445. .\" init listcounter
  1446. .nr li*cnt!\\n[li*lvl] 0 1
  1447. .\" assign format
  1448. .af li*cnt!\\n[li*lvl] 1
  1449. .if \\n[li*type] .if !'\\*[li*mark]'' .af li*cnt!\\n[li*lvl] \\*[li*mark]
  1450. .\"
  1451. .if \\n[li*lb-spc] .SP \\n[li*lb-spc]v/2u
  1452. .in +\\n[li*tind]u
  1453. ..
  1454. .\"---------------
  1455. .de LI
  1456. .if \\n[li*lvl]<1 .@error "LI:no lists active"
  1457. .if \\n[li*li-spc]&(\\n[Ls]>=\\n[li*lvl]) .SP \\n[li*li-spc]v/2u
  1458. .ne 2v
  1459. .\"
  1460. .ds li*c-mark \\*[li*mark]
  1461. .nr li*cnt!\\n[li*lvl] +1
  1462. .if \\n[li*type]=1 .ds li*c-mark \\n[li*cnt!\\n[li*lvl]].
  1463. .if \\n[li*type]=2 .ds li*c-mark \\n[li*cnt!\\n[li*lvl]])
  1464. .if \\n[li*type]=3 .ds li*c-mark (\\n[li*cnt!\\n[li*lvl]])
  1465. .if \\n[li*type]=4 .ds li*c-mark [\\n[li*cnt!\\n[li*lvl]]]
  1466. .if \\n[li*type]=5 .ds li*c-mark <\\n[li*cnt!\\n[li*lvl]]>
  1467. .if \\n[li*type]=6 .ds li*c-mark {\\n[li*cnt!\\n[li*lvl]]}
  1468. .if \\n[.$]=1 .ds li*c-mark \\$1
  1469. .if \\n[.$]=2 .ds li*c-mark \\$1\ \\*[li*c-mark]
  1470. .if '\\*[li*c-mark]'\ ' .ds li*c-mark
  1471. .\"
  1472. .\" determine where the text begins
  1473. .nr li*text-begin \\n[li*tind]>?\w@\\*[li*c-mark]\ @
  1474. .\"
  1475. .\" determine where the mark begin
  1476. .ie !\\n[li*pad] .nr li*in \\n[li*mind]
  1477. .el .nr li*in \\n[li*text-begin]-\\n[li*pad]-\w@\\*[li*c-mark]@
  1478. .if !\\n[li*in] .nr li*in 0
  1479. .\"
  1480. .ti -\\n[li*tind]u
  1481. .\" no indentation if hanging indent
  1482. .if (\w@\\*[li*c-mark]@=0)&((\\n[.$]=0):(\w@\\$1@=0)) .nr li*text-begin 0
  1483. \Z'\&\h'\\n[li*in]u'\\*[li*c-mark]'\h'\\n[li*text-begin]u'\&\c
  1484. .if \\n[li*type]=-1 .br
  1485. ..
  1486. .\"
  1487. .\"-------------
  1488. .de li@pop
  1489. .nr li*lvl -1
  1490. .misc@pop-nr cind li*tmp
  1491. .in \\n[li*tmp]u
  1492. .misc@pop-nr tind li*tind
  1493. .misc@pop-nr mind li*mind
  1494. .misc@pop-nr pad li*pad
  1495. .misc@pop-nr type li*type
  1496. .misc@pop-nr li-spc li*li-spc
  1497. .ds li*mark \\*[li*mark-list!\\n[li*lvl]]
  1498. ..
  1499. .de LE
  1500. .if \\n[li*lvl]<1 .@error "LE:mismatched"
  1501. .li@pop
  1502. .if '\\$1'1' .SP .5
  1503. ..
  1504. .\"-------------
  1505. .\"    list status clear.
  1506. .de LC
  1507. .if !\\n[.$]=1 .@error "LC: no argument"
  1508. .if \\$1>\\n[li*lvl] .@error "LC: incorrect argument: \\$1 (too big)"
  1509. .while \\n[li*lvl]>\\$1 .li@pop
  1510. .nr par@ind-flag 0
  1511. ..
  1512. .\"-------------
  1513. .de AL
  1514. .if \\n[.$]>3 .@error "AL: too many arguments"
  1515. .if \\n[D]>2 .tm AL $*
  1516. .ie \\n[.$]<=1 .LB \\n[Li] 0 2 1 "\\$1"
  1517. .el \{\
  1518. .    ie \\n[.$]=2 .LB 0\\$2 0 2 1 "\\$1"
  1519. .    el \{\
  1520. .        ie !'\\$2'' .LB \\$2 0 2 1 "\\$1" 0 1
  1521. .        el .LB \\n[Li] 0 2 1 "\\$1" 0 1
  1522. .    \}
  1523. .\}
  1524. ..
  1525. .de ML
  1526. .if \\n[.$]>3 .@error "ML: too many arguments"
  1527. .if \\n[D]>2 .tm ML $*
  1528. .nr li*ml-width \w@\\$1@u+1n
  1529. .if \\n[.$]<2 .LB \\n[li*ml-width]u 0 1 0 "\\$1"
  1530. .if \\n[.$]=2 .LB 0\\$2 0 1 0 "\\$1"
  1531. .if \\n[.$]=3 \{\
  1532. .    ie '\\$2'' .LB \\n[li*ml-width]u 0 1 0 "\\$1" 0 1
  1533. .    el .LB \\n[Li] 0 1 0 "\\$1" 0 1
  1534. .\}
  1535. ..
  1536. .de VL
  1537. .if \\n[D]>2 .tm VL $*
  1538. .if \\n[.$]>3 .@error "VL: too many arguments"
  1539. .if \\n[.$]<1 .@error "VL: missing text-indent"
  1540. .ie \\n[.$]<3 .LB 0\\$1 0\\$2 0 0
  1541. .el .LB 0\\$1 0\\$2 0 0 \& 0 1
  1542. ..
  1543. .\"    Bullet (for .BL)
  1544. .de BL
  1545. .if \\n[D]>2 .tm BL $*
  1546. .ds BU \s-2\(bu\s0
  1547. .if \\n[.$]>2 .@error "BL: too many arguments"
  1548. .if \\n[.$]<1 .LB \\n[Pi] 0 1 0 \\*[BU]
  1549. .if \\n[.$]=1 .LB 0\\$1 0 1 0 \\*[BU]
  1550. .if \\n[.$]=2 \{\
  1551. .    ie '\\$1'' .LB \\n[Pi] 0 1 0 \\*[BU] 0 1
  1552. .    el .LB 0\\$1 0 1 0 \\*[BU] 0 1
  1553. .\}
  1554. ..
  1555. .de DL
  1556. .if \\n[D]>2 .tm DL $*
  1557. .if \\n[.$]>2 .@error "DL: too many arguments"
  1558. .if \\n[.$]<=1 .LB \\n[Pi] 0 1 0 \(em
  1559. .if \\n[.$]=1 .LB 0\\$1 0 1 0 \(em
  1560. .if \\n[.$]=2 \{\
  1561. .    ie '\\$1'' .LB \\n[Pi] 0 1 0 \(em 0 1
  1562. .    el .LB 0\\$1 0 1 0 \(em 0 1
  1563. .\}
  1564. ..
  1565. .de RL
  1566. .if \\n[D]>2 .tm RL $*
  1567. .if \\n[.$]>2 .@error "RL: too many arguments"
  1568. .if \\n[.$]<1 .LB 6 0 2 4
  1569. .if \\n[.$]=1 .LB 0\\$1 0 2 4
  1570. .if \\n[.$]=2 \{\
  1571. .    ie '\\$1'' .LB 6 0 2 4 1 0 1
  1572. .    el .LB 0\\$1 0 2 4 1 0 1
  1573. .\}
  1574. ..
  1575. .\" Broken Variable List. As .VL but text begin on the next line
  1576. .de BVL
  1577. .if \\n[D]>2 .tm BVL $*
  1578. .if \\n[.$]>3 .@error "BVL: too many arguments"
  1579. .if \\n[.$]<1 .@error "BVL: missing text-indent"
  1580. .ie \\n[.$]<3 .LB 0\\$1 0\\$2 0 -1
  1581. .el .LB 0\\$1 0\\$2 0 -1 \& 0 1
  1582. ..
  1583. .\" ####### module tbl #######################################
  1584. .\" This module is copied from groff_ms and modified for mgm.
  1585. .\" Yes, it does not resemble the original anymore :-).
  1586. .\" Don't know if I missed something important.
  1587. .\" Groff_ms is written by James Clark.
  1588. .nr tbl*have-header 0
  1589. .nr tbl*header-written 0
  1590. .de TS
  1591. .br
  1592. .if ''\\n[.z]' .SP
  1593. .if '\\$1'H' .di tbl*header-div
  1594. ..
  1595. .de tbl@top-hook
  1596. .if \\n[tbl*have-header] \{\
  1597. .    ie \\n[.t]-\\n[tbl*header-ht]-1v .tbl@print-header
  1598. .    el .sp \\n[.t]u
  1599. .\}
  1600. ..
  1601. .de tbl@bottom-hook
  1602. .if \\n[tbl*have-header] \{\
  1603. .    nr T. 1
  1604. .\" draw bottom and side lines of boxed tables.
  1605. .    T#
  1606. .\}
  1607. .nr tbl*header-written 0
  1608. ..
  1609. .de tbl@print-header
  1610. .ev tbl*ev
  1611. 'nf
  1612. .tbl*header-div
  1613. .ev
  1614. .mk #T
  1615. .nr tbl*header-written 1
  1616. ..
  1617. .de TH
  1618. .ie '\\n[.z]'tbl*header-div' \{\
  1619. .    nr T. 0
  1620. .    T#
  1621. .    br
  1622. .    di
  1623. .    nr tbl*header-ht \\n[dn]
  1624. .    ne \\n[dn]u+1v
  1625. .    nr tbl*have-header 1
  1626. .    ie '\\$1'N' .if !\\n[tbl*header-written] .tbl@print-header
  1627. .    el .tbl@print-header
  1628. .\}
  1629. .el .@error ".TH without .TS H"
  1630. ..
  1631. .de TE
  1632. .ie '\\n(.z'tbl*header-div' .@error ".TS H but no .TH before .TE"
  1633. .el \{\
  1634. .    nr tbl*have-header 0
  1635. .\}
  1636. .\" reset tabs
  1637. .TAB
  1638. ..
  1639. .de T&
  1640. ..
  1641. .\" ####### module pic #######################################
  1642. .de PS
  1643. .nr pic*in 0
  1644. .br
  1645. .SP .5
  1646. .ie \\n[.$]<2 .@error "PS: bad arguments. Probably not processed with pic."
  1647. .el \{\
  1648. .    if !\\n[ds*lvl] .ne (u;\\$1)+1v
  1649. .\" should be contained between .DS/.DE
  1650. .if r ds*format \{\
  1651. .        if \\n[ds*lvl]&((\\n[ds*format]=2):(\\n[ds*format]=3)) \{\
  1652. .            nr pic*in \\n[.i]
  1653. .\" .        in +(u;\\n[.l]-\\n[.i]-\\$2/2)
  1654. .        \}
  1655. .    \}
  1656. .\}
  1657. ..
  1658. .de PE
  1659. .init@reset
  1660. .SP .5
  1661. ..
  1662. .\" ####### module eq #######################################
  1663. .\" 
  1664. .nr eq*number 0 1
  1665. .de EQ
  1666. .ds eq*lable "\\$1
  1667. .di eq*div
  1668. .misc@ev-keep eq*ev
  1669. .in 0
  1670. .nf
  1671. ..
  1672. .de EN
  1673. .br
  1674. .di
  1675. .ta
  1676. .\" equation with lable.
  1677. .if \\n[dl] \{\
  1678. .    br
  1679. .    chop eq*div
  1680. .    ie (\\n[Eq]%2) \{\
  1681. .        \"    lable to the left
  1682. .        if \\n[ds*format]<2 \{\
  1683. .            ta (u;(\\n[.l]/7)+\\n[.i]) \\n[.l]u\" L
  1684. \\*[eq*lable]\t\\*[eq*div]\t\&
  1685. .        \}
  1686. .        if (\\n[ds*format]=2):(\\n[ds*format]=3) \{\
  1687. .            ta (u;(\\n[.l]-\\n[.i])/2+\\n[.i])C \\n[.l]u\" C
  1688. \\*[eq*lable]\t\\*[eq*div]\t\&
  1689. .        \}
  1690. .        if \\n[ds*format]>3 \{\
  1691. .            ta \\n[.l]uR\"    R
  1692. \\*[eq*lable]\t\\*[eq*div]
  1693. .        \}
  1694. .    \}
  1695. .    el \{\
  1696. .        \"    lable to the right
  1697. .        if \\n[ds*format]<2 \{\
  1698. .            ta \\n[.l]uR\" L
  1699. \\*[eq*div]\t\\*[eq*lable]
  1700. .        \}
  1701. .        if (\\n[ds*format]=2):(\\n[ds*format]=3) \{\
  1702. .            ta (u;(\\n[.l]-\\n[.i])/2+\\n[.i])C \\n[.l]uR\" C
  1703. \t\\*[eq*div]\t\\*[eq*lable]
  1704. .        \}
  1705. .        if \\n[ds*format]>3 \{\
  1706. .            ta (\\n[.l]u-\w@\\*[eq*lable]@u-1m)R \\n[.l]uR\" R
  1707. \t\\*[eq*div]\t\\*[eq*lable]
  1708. .        \}
  1709. .    \}
  1710. .\}
  1711. .TAB
  1712. .ev
  1713. ..
  1714. .\"########### module toc ###################
  1715. .\" table of contents
  1716. .nr toc*slevel 1
  1717. .nr toc*spacing 1v/2u
  1718. .nr toc*tlevel 2
  1719. .nr toc*tab 0
  1720. .\"-----------
  1721. .\" Table of contents with friends (module lix)
  1722. .de TC
  1723. .br
  1724. .\" print any pending displays
  1725. .pg@end-of-text
  1726. .if \w@\\$1@>0 .nr toc*slevel \\$1
  1727. .if \w@\\$2@>0 .nr toc*spacing \\$2v/2u
  1728. .if \w@\\$3@>0 .nr toc*tlevel \\$3
  1729. .if \w@\\$4@>0 .nr toc*tab \\$4
  1730. .if \\n[pg*cols-per-page]>1 .1C
  1731. .pg@clear-hd
  1732. .pg@next-page
  1733. .pg@clear-ft
  1734. .\"-------------
  1735. .if d Ci .toc@read-Ci \\*[Ci]
  1736. .nf
  1737. .in 0
  1738. .nr toc*pn 0 1
  1739. .af toc*pn i
  1740. .PF "''\\\\\\\\n+[toc*pn]''"
  1741. .nr toc*i 4 1
  1742. .while \\n+[toc*i]<10 \{\
  1743. .    if !'\\$\\n[toc*i]'' \{\
  1744. .        ce
  1745. \\$\\n[toc*i]
  1746. .        br
  1747. .    \}
  1748. .\}
  1749. .if \\n[.$]<=4 .if d TX .TX
  1750. .ie d TY .if \\n[.$]<=4 .TY
  1751. .el \{\
  1752. .    ce
  1753. \\*[Licon]
  1754. .    br
  1755. .    SP 3
  1756. .\}
  1757. .toc*list
  1758. .\" print LIST OF XXX
  1759. .if d lix*dsfg .lix@print-ds fg "\\*[Lf]"
  1760. .if d lix*dstb .lix@print-ds tb "\\*[Lt]"
  1761. .if d lix*dsec .lix@print-ds ec "\\*[Le]"
  1762. .if d lix*dsex .lix@print-ds ex "\\*[Lx]"
  1763. ..
  1764. .\"-----------
  1765. .\" .toc@read-Ci lev1 lev2 lev3 lev4 ... lev7
  1766. .de toc@read-Ci
  1767. .nr toc*i 0 1
  1768. .while \\n+[toc*i]<8 \{\
  1769. .    nr toc*hl!\\n[toc*i] \\$\\n[toc*i]
  1770. .\}
  1771. ..
  1772. .\"-----------
  1773. .de toc@save
  1774. .\" collect maxsize of mark if string Ci don't exist.
  1775. .if !d Ci \{\
  1776. .    if !r toc*hl!\\$1 .nr toc*hl!\\$1 0
  1777. .    if \\n[toc*hl!\\$1]<\w@\\$2@ \{\
  1778. .        nr toc*hl!\\$1 \w@\\$2@u+1m
  1779. .    \}
  1780. .\}
  1781. .am toc*list
  1782. .\" .toc@set level headernumber text pagenr
  1783. .toc@set \\$1 "\\$2" "\\$3" \\$4
  1784. \\..
  1785. ..
  1786. .\"-----------
  1787. .\" level mark text pagenumber
  1788. .de toc@set
  1789. .if \\$1<=\\n[toc*slevel] .SP \\n[toc*spacing]u
  1790. .ne 2v
  1791. .na
  1792. .fi
  1793. .nr toc*ind 0
  1794. .nr toc*i 0 1
  1795. .ie d Ci \{\
  1796. .    nr toc*ind +\\n[toc*hl!\\$1]u
  1797. .\}
  1798. .el \{\
  1799. .    while \\n+[toc*i]<\\$1 \{\
  1800. .        nr toc*ind +\\n[toc*hl!\\n[toc*i]]u
  1801. .    \}
  1802. .\}
  1803. .nr toc*text \\n[toc*ind]u+\\n[toc*hl!\\$1]u
  1804. .in \\n[toc*text]u
  1805. .ti -\\n[toc*hl!\\$1]u
  1806. .\"
  1807. .\" length of headernum space
  1808. .nr toc*i \\n[toc*hl!\\$1]-\w@\\$2@
  1809. .\"
  1810. .ll \\n[@ll]u-\w@\\$4@u-2m
  1811. .\" ragged right ---------------------------------
  1812. .ie \\$1>\\n[toc*tlevel] \{\
  1813. \\$2
  1814. .    sp -1
  1815. \\$3\ \ \ \\$4
  1816. .    br
  1817. .\}
  1818. .el \{\
  1819. .    \" unnumbered heading --------------------
  1820. .    ie '\\$2'' \{\
  1821. .        in \\n[toc*ind]u
  1822. \\$3\h'1m'
  1823. .    \}
  1824. .    \" normal heading ------------------------
  1825. .    el \{\
  1826. \\$2
  1827. .        sp -1
  1828. \\$3\h'1m'
  1829. .    \}
  1830. .    ll \\n[@ll]u
  1831. .    sp -1
  1832. .    nr toc*sep (u;\\n[.l]-\\n[.n]-\\n[.i]-\w@\\$4@)-1m
  1833. \h'|\\n[.n]u'\l'\\n[toc*sep]u.'\h'1m'\\$4
  1834. .\}
  1835. .ll \\n[@ll]u
  1836. ..
  1837. .\"########################### module lix ############################
  1838. .\" LIST OF figures, tables, exhibits and equations 
  1839. .nr lix*fg-nr 0 1
  1840. .nr lix*tb-nr 0 1
  1841. .nr lix*ec-nr 0 1
  1842. .nr lix*ex-nr 0 1
  1843. .aln Fg lix*fg-nr
  1844. .aln Tb lix*tb-nr
  1845. .aln Ec lix*ec-nr
  1846. .aln Ex lix*ex-nr
  1847. .\"------------
  1848. .de FG
  1849. .lix@print-line fg Lf \\n+[lix*fg-nr] "\\$1" "\\$2" "\\$3" "\\$4"
  1850. ..
  1851. .de TB
  1852. .lix@print-line tb Lt \\n+[lix*tb-nr] "\\$1" "\\$2" "\\$3" "\\$4"
  1853. ..
  1854. .de EC
  1855. .lix@print-line ec Le \\n+[lix*ec-nr] "\\$1" "\\$2" "\\$3" "\\$4"
  1856. ..
  1857. .de EX
  1858. .lix@print-line ex Lx \\n+[lix*ex-nr] "\\$1" "\\$2" "\\$3" "\\$4"
  1859. ..
  1860. .\"------------
  1861. .\" print line with 'figure' in the text
  1862. .\" type stringvar number text override flag refname
  1863. .de lix@print-line
  1864. .ds lix*text "\\$4
  1865. .ie !\\n[Of] .ds lix*ds-form .\ \ \"
  1866. .el .ds lix*ds-form "\ \(em\ \"
  1867. .nr lix*in \\n[.i]
  1868. .ds lix*lable \\*[Li\\$1]\ \\$3\\*[lix*ds-form]
  1869. .if !'\\$5'' \{\
  1870. .    if !0\\$6 .ds lix*lable \\*[Li\\$1]\ \\$5\\$3\\*[lix*ds-form]
  1871. .    if 0\\$6=1 .ds lix*lable \\*[Li\\$1]\ \\$3\\$5\\*[lix*ds-form]
  1872. .    if 0\\$6=2 .ds lix*lable \\*[Li\\$1]\ \\$5\\*[lix*ds-form]
  1873. .\}
  1874. .ds lix*pgnr \\n[%]
  1875. .\" print line if not between DS/DE
  1876. .ie \\n[ds*lvl]<1 .lix@print-text "\\*[lix*lable]" "\\*[lix*text]"
  1877. .el .lix@embedded-text "\\*[lix*lable]" "\\*[lix*text]"
  1878. .\"
  1879. .\" save line for LIST OF XXX
  1880. .if !r lix*wth\\$1 .nr lix*wth\\$1 0
  1881. .if \w@\\*[lix*lable]@>\\n[lix*wth\\$1] .nr lix*wth\\$1 \w@\\*[lix*lable]@
  1882. .if \\n[\\$2] .lix@ds-save \\$1 \\*[lix*pgnr] "\\$4" "\\*[lix*lable]"
  1883. .if !'\\$7'' .SETR \\$7 \\$3
  1884. ..
  1885. .\"-----------
  1886. .de lix@print-text
  1887. .SP \\n[Lsp]u
  1888. .misc@ev-keep lix
  1889. .init@reset
  1890. .br
  1891. .ie (\w@\\$1\\$2@)>(\\n[.l]-\\n[.i]) \{\
  1892. .    in +\w@\\$1@u
  1893. .    ti 0
  1894. .\}
  1895. .el .ce 1
  1896. \fB\\$1\fP\\$2
  1897. .br
  1898. .ev
  1899. ..
  1900. .\" hide printout until diversion is evaluated
  1901. .de lix@embedded-text
  1902. \!.SP \\n[Lsp]u
  1903. \!.misc@ev-keep lix
  1904. \!.init@reset
  1905. \!.br
  1906. \!.ie (\w@\\$1\\$2@)>(\\n[.l]-\\n[.i]) \{\
  1907. \!.    in +\w@\\$1@u
  1908. \!.    ti 0
  1909. \!.\}
  1910. \!.el .ce 1
  1911. \!\fB\\$1\fP\\$2
  1912. \!.br
  1913. \!.ev
  1914. ..
  1915. .\"------------
  1916. .\" print complete list of XXXX
  1917. .de lix@print-ds
  1918. .\" arg: fg,tb,ec,ex text
  1919. .if !\\n[Cp] .pg@next-page
  1920. .\" print LIST OF XXXX
  1921. .ce
  1922. \\$2
  1923. .SP 3
  1924. .in \\n[lix*wth\\$1]u
  1925. .fi
  1926. .lix*ds\\$1
  1927. ..
  1928. .\"------------
  1929. .\" save line of list in macro
  1930. .de lix@ds-save
  1931. .\" type pagenumber text
  1932. .am lix*ds\\$1
  1933. .lix@dsln \\$1 \\$2 "\\$3" "\\$4" \\$5
  1934. \\..
  1935. ..
  1936. .\"------------
  1937. .\" print appended macro
  1938. .\" lix@dsln type pagenumber text headernr
  1939. .de lix@dsln
  1940. .nr lix*i \\n[lix*wth\\$1]-\w@\\$4@
  1941. .ne 2v
  1942. .ll -4m
  1943. .ti 0
  1944. \h'\\n[lix*i]u'\\$4\\$3
  1945. .sp -1
  1946. .ll
  1947. .ti \\n[.l]u-\w@\\$2@u
  1948. \\$2
  1949. ..
  1950. .\"########################### module fnt ############################
  1951. .\" some font macros.
  1952. .de R
  1953. .ft R
  1954. .ul 0
  1955. ..
  1956. .\"-----------
  1957. .de fnt@switch
  1958. .ul 0
  1959. .ds fnt*tmp
  1960. .nr fnt*prev \\n[.f]
  1961. .nr fnt*i 2 1
  1962. .while \\n+[fnt*i]<=\\n[.$] \{\
  1963. .    if \\n[fnt*i]>3 .as fnt*tmp \,
  1964. .    ie (\\n[fnt*i]%2)=1 .as fnt*tmp \\$1\\$[\\n[fnt*i]]
  1965. .    el .as fnt*tmp \\$2\\$[\\n[fnt*i]]
  1966. .    if \\n[fnt*i]<\\n[.$] .as fnt*tmp \/
  1967. .\}
  1968. \\*[fnt*tmp]\f[\\n[fnt*prev]]
  1969. ..
  1970. .\"-----------
  1971. .de B
  1972. .ie \\n[.$] .fnt@switch \fB \f[\\n[.f]] \\$@
  1973. .el .ft B
  1974. ..
  1975. .de I
  1976. .ie \\n[.$] .fnt@switch \fI \f[\\n[.f]] \\$@
  1977. .el .ft I
  1978. ..
  1979. .de IB
  1980. .if \\n[.$] .fnt@switch \fI \fB \\$@
  1981. ..
  1982. .de BI
  1983. .if \\n[.$] .fnt@switch \fB \fI \\$@
  1984. ..
  1985. .de IR
  1986. .if \\n[.$] .fnt@switch \fI \fR \\$@
  1987. ..
  1988. .de RI
  1989. .if \\n[.$] .fnt@switch \fR \fI \\$@
  1990. ..
  1991. .de RB
  1992. .if \\n[.$] .fnt@switch \fR \fB \\$@
  1993. ..
  1994. .de BR
  1995. .if \\n[.$] .fnt@switch \fB \fR \\$@
  1996. ..
  1997. .\"########################### module box ############################
  1998. .\" draw a box around some text. Text will be kept on the same page.
  1999. .\"
  2000. .nr box*ll 0
  2001. .\" .B1 and .B2 works like .DS
  2002. .de B1
  2003. .if \\n[box*ll] .@error "B1: missing B2"
  2004. .nr box*ll \\n[.l]
  2005. .nr box*ind \\n[.i]
  2006. .nr box*hyp \\n[.hy]
  2007. .in +1n
  2008. .ll -1n
  2009. .di box*div
  2010. .hy \\n[.hy]
  2011. ..
  2012. .de B2
  2013. .if !\\n[box*ll] .@error "B2: missing B1"
  2014. .br
  2015. .di
  2016. .nr box*height \\n[dn]
  2017. .ne \\n[dn]u+1v
  2018. .ev box*ev
  2019. .ll \\n[box*ll]u
  2020. .in 0
  2021. .nr box*y-pos \\n[.d]u
  2022. .nf
  2023. .box*div
  2024. .fi
  2025. \v'-1v+.25m'\
  2026. \D'l \\n[.l]u 0'\
  2027. \D'l 0 -\\n[box*height]u'\
  2028. \D'l -\\n[.l]u 0'\
  2029. \D'l 0 \\n[box*height]u'
  2030. .br
  2031. .sp -1
  2032. .ev
  2033. .sp .20v
  2034. .in \\n[box*ind]u
  2035. .ll \\n[box*ll]u
  2036. .rm box*div
  2037. .nr box*ll 0
  2038. ..
  2039. .\"########################### module ref ############################
  2040. .nr ref*nr 0 1
  2041. .nr ref*nr-width 5n
  2042. .ds Rf \v'-.4m'\s-3[\\n+[ref*nr]]\s0\v'.4m'
  2043. .\" start reference
  2044. .de RS
  2045. .if !''\\$1' .ds \\$1 \\n[ref*nr]
  2046. .ev ref*ev
  2047. .da ref*div
  2048. .init@reset
  2049. .ll \\n[@ll]u
  2050. .in \\n[ref*nr-width]u
  2051. .ti -(\w@\\n[ref*nr].@u+1n)
  2052. \\n[ref*nr].
  2053. .sp -1
  2054. ..
  2055. .de RF
  2056. .br
  2057. .if \\n[Ls] .SP .5
  2058. .di
  2059. .ev
  2060. ..
  2061. .de RP
  2062. .if !d ref*div .@error "RP: No references!"
  2063. .nr ref*i 0\\$2
  2064. .if \\n[ref*i]<2 .SK
  2065. .SP 2
  2066. .toc@save 1 "" "\\*[Rp]" \\n[%]
  2067. .ev ref*ev
  2068. .ce
  2069. \fI\\*[Rp]\fP
  2070. .sp
  2071. .in 0
  2072. .nf
  2073. .ref*div
  2074. .in
  2075. .if 0\\$1<1 .nr ref*nr 0 1
  2076. .rm ref*div
  2077. .ev
  2078. .if (\\n[ref*i]=0:\\n[ref*i]=2) .SK
  2079. ..
  2080. .\"########################### module app ############################
  2081. .\" 
  2082. .nr app*nr 0 1
  2083. .af app*nr A
  2084. .nr app*dnr 0 1
  2085. .\"------------
  2086. .\" .APP name text
  2087. .\" name == "" -> autonumber
  2088. .de APP
  2089. .if \\n[.$]<2 .@error "APP: too few arguments"
  2090. .app@set-ind "\\$1"
  2091. .\"
  2092. .ie \\n[Aph] .app@header \\*[app*ind] "\\$2"
  2093. .el .bp
  2094. .app@index "\\*[app*ind]" "\\$2"
  2095. ..
  2096. .\"------------
  2097. .\" .APPSK name pages text
  2098. .\" name == "" -> autonumber
  2099. .de APPSK
  2100. .if \\n[.$]<2 .@error "APPSK: too few arguments"
  2101. .app@set-ind "\\$1"
  2102. .\"
  2103. .ie \\n[Aph] .app@header \\*[app*ind] "\\$3"
  2104. .el .bp
  2105. .app@index "\\*[app*ind]" "\\$3"
  2106. .pn +\\$2
  2107. ..
  2108. .\"------------
  2109. .de app@set-ind
  2110. .ie \w@\\$1@ .ds app*ind \\$1
  2111. .el \{\
  2112. .    if !\\n[app*dnr] \{\
  2113. .        nr H1 0 1
  2114. .        af H1 A
  2115. .    \}
  2116. .    ds app*ind \\n+[app*nr]
  2117. .    nr H1 \\n+[app*dnr]
  2118. .\}
  2119. .\"    clear lower counters
  2120. .nr app*i 1 1
  2121. .while \\n+[app*i]<8 .nr H\\n[app*i] 0 1
  2122. ..
  2123. .\"------------
  2124. .de app@index
  2125. .toc@save 1 "" "\\*[App] \\$1: \\$2" \\n[%]
  2126. ..
  2127. .\"------------
  2128. .\" app@heaer name text
  2129. .de app@header
  2130. .bp
  2131. .SP \\n[Lsp]u*4u
  2132. .ce 1
  2133. \s+4\fB\\*[App]\ \\$1\fP\s0
  2134. .SP \\n[Lsp]u*2u
  2135. .if \w@\\$2@<\\n[.l] .ce 1
  2136. \fB\s+2\\$2\s0\fP
  2137. .SP \\n[Lsp]u*4u
  2138. ..
  2139. .\"########################### module cov ############################
  2140. .\" title stored in diversion cov*title
  2141. .\" abstract stored in diversion cov*abstract
  2142. .\"    arg to abstract stored in cov*abs-arg
  2143. .\"    indent stored in cov*abs-ind
  2144. .\" number of authors stored in cov*au
  2145. .\" author(s) stored in cov*au!x!y
  2146. .\" author(s) title stored in cov*at!x!y
  2147. .\"     x is the author-index [1-cov*au], y is the argument-index [1-9].
  2148. .\" author(s) firm stored in cov*firm
  2149. .\" new date (if .ND exists) is stored in cov*new-date
  2150. .\"
  2151. .\"
  2152. .ds cov*abs-name ABSTRACT
  2153. .\"
  2154. .nr cov*au 0
  2155. .de TL
  2156. .if \\n[.$]>0 .ds cov*title-charge-case \\$1
  2157. .if \\n[.$]>1 .ds cov*title-file-case \\$2
  2158. .pg@disable-top-trap
  2159. .eo
  2160. .de cov*title AU
  2161. ..
  2162. .\"-------------------
  2163. .de cov@title-end
  2164. .ec
  2165. ..
  2166. .\"-------------------
  2167. .\" .AU name [initials [loc [dept [ext [room [arg [arg [arg]]]]]]]]
  2168. .de AU
  2169. .cov@title-end
  2170. .pg@disable-top-trap
  2171. .if \\n[.$]<1 .@error "AU: no arguments"
  2172. .nr cov*au +1
  2173. .nr cov*i 0 1
  2174. .while \\n[.$]>=\\n+[cov*i] \{\
  2175. .    ds cov*au!\\n[cov*au]!\\n[cov*i] "\\$[\\n[cov*i]]
  2176. .\}
  2177. .if (\\n[.$]>=3)&(\w@\\$3@) \{\
  2178. .    if d cov*location-\\$3] \{\
  2179. .        ds cov*au!3!\\n[cov*au] \\*[cov*location-\\$3]
  2180. .    \}
  2181. .\}
  2182. ..
  2183. .\"-------------------
  2184. .\" .AT title1 [title2 [... [title9] ]]]]
  2185. .\" Well, thats all that COVEND look for.
  2186. .\" Must appear directly after .AU
  2187. .de AT
  2188. .if \\n[.$]<1 .@error "AT: no arguments"
  2189. .nr cov*i 0 1
  2190. .while \\n[.$]>=\\n+[cov*i] \{\
  2191. .    ds cov*at!\\n[cov*au]!\\n[cov*i] "\\$[\\n[cov*i]]
  2192. .\}
  2193. ..
  2194. .\"-------------------
  2195. .de AF
  2196. .cov@title-end
  2197. .if \\n[.$]<1 .@error "AF: no arguments"
  2198. .ds cov*firm \\$1
  2199. ..
  2200. .de AST
  2201. .ds cov*abs-name \\$1
  2202. ..
  2203. .de AS
  2204. .pg@disable-top-trap
  2205. .if d cov*abstract .@error "AS: only one abstract allowed"
  2206. .if !''\\n[.z]' .@error "AS: no diversion allowed (previous .AS?)"
  2207. .nr cov*abs-arg 0\\$1
  2208. .nr cov*abs-ind (n;0\\$2)
  2209. .de cov*abstract AE
  2210. ..
  2211. .de AE
  2212. ..
  2213. .\" I am planning to use mgm some time :-)
  2214. .ie \\n[yr]<50 .ds cov*new-date \\*[MO\\n[mo]] \\n[dy], 20\\n[yr]
  2215. .el .ds cov*new-date \\*[MO\\n[mo]] \\n[dy], 19\\n[yr]
  2216. .als DT cov*new-date
  2217. .de ND
  2218. .\" don't remember why I did this: .pg@disable-top-trap
  2219. .ds cov*new-date \\$1
  2220. ..
  2221. .\"-------------------
  2222. .\" save technical numbers.
  2223. .de TM
  2224. .nr cov*i 0 1
  2225. .while \\n[.$]>=\\n+[cov*i] .ds cov*mt-tm!\\n[cov*i] \\$[\\n[cov*i]]
  2226. .nr cov*mt-tm-max \\n[.$]
  2227. ..
  2228. .\"-----------------------
  2229. .\" cover sheet
  2230. .\" the file must have the following last lines (somewhere):
  2231. .\" .pg@enable-top-trap
  2232. .\" .bp 1
  2233. .\" .pg@enable-trap
  2234. .ds cov*mt-file!0 0.MT
  2235. .ds cov*mt-file!1 0.MT
  2236. .ds cov*mt-file!2 0.MT
  2237. .ds cov*mt-file!3 0.MT
  2238. .ds cov*mt-file!4 4.MT
  2239. .ds cov*mt-file!5 5.MT
  2240. .ds cov*mt-file!6 0.MT
  2241. .\"------------
  2242. .de MT
  2243. .ie \\n[.$] \{\
  2244. .    ie d cov*mt-file!\\$1 .ds cov*mt-type \\$1
  2245. .    el .ds cov*mt-type 6
  2246. .\}
  2247. .el .ds cov*mt-type 1
  2248. .ds cov*mt-addresse "\\$2
  2249. .ds cov*mt-type-text "\\$1
  2250. .ie d @language .ds cov*str mm/\\*[@language]_
  2251. .el .ds cov*str mm/
  2252. .mso \\*[cov*str]\\*[cov*mt-file!\\*[cov*mt-type]]
  2253. ..
  2254. .de COVER
  2255. .ie !\\n[.$] .ds cov*cov-type ms
  2256. .el .ds cov*cov-type \\$1
  2257. .pg@disable-top-trap
  2258. .ie d @language .ds cov*str mm/\\*[@language]_\\*[cov*cov-type].cov
  2259. .el .ds cov*str mm/\\*[cov*cov-type].cov
  2260. .mso \\*[cov*str]
  2261. ..
  2262. .\"########################### module qrf ############################
  2263. .\" forward and backward reference thru special files.
  2264. .\"
  2265. .\" init reference system
  2266. .de INITR
  2267. .if \\n[.$]<1 .@error "INITR:filename missing"
  2268. .\" ignore if INITR has already been used
  2269. .if !r qrf*pass \{\
  2270. .\"
  2271. .    ds qrf*file \\$1
  2272. .    sy test -f \\*[qrf*file].tmp
  2273. .    ie \\n[systat] \{\
  2274. .        \" PASS 1
  2275. .        if \\n[D]=1 .tm PASS 1
  2276. .        if \\n[D]>1 .tm INITR: file \\*[qrf*file].tmp, PASS 1
  2277. .        nr qrf*pass 1
  2278. .        open qrf*stream \\*[qrf*file].tmp
  2279. .        write qrf*stream .\\\\" references for \\*[qrf*file]
  2280. .        close qrf*stream
  2281. .    \}
  2282. .    el \{\
  2283. .        nr qrf*pass 2
  2284. .        if \\n[D]=1 .tm PASS 2
  2285. .        if \\n[D]>1 .tm INITR: file \\*[qrf*file].tmp, PASS 2
  2286. .        sy mv  \\*[qrf*file].tmp  \\*[qrf*file].qrf
  2287. '        so  \\*[qrf*file].qrf
  2288. .    \}
  2289. .\}
  2290. ..
  2291. .\"---------------
  2292. .\" set a reference.
  2293. .de SETR
  2294. .if \\n[.$]<1 .@error "SETR:reference name missing"
  2295. .ie !r qrf*pass .tm "SETR: No .INITR in this file"
  2296. .el \{\
  2297. .    ds qrf*name qrf*ref-\\$1
  2298. .\" probably pass two if already defined
  2299. .    if \\n[qrf*pass]<2 \{\
  2300. .        if \\n[D]>2 .tm SETR: ref \\*[qrf*name]=\\*[hd*toc-mark],\\n[%]
  2301. .        \" heading-number
  2302. .        ds \\*[qrf*name]-hn \\*[hd*toc-mark]
  2303. .        \" page-number
  2304. .        ds \\*[qrf*name]-pn \\n[%]
  2305. .        \"
  2306. .        \" append to file
  2307. .        opena qrf*stream \\*[qrf*file].tmp
  2308. .        write qrf*stream .ds \\*[qrf*name]-hn \\*[hd*toc-mark]
  2309. .        write qrf*stream .ds \\*[qrf*name]-pn \\n[%]
  2310. .        if !'\\$2'' .write qrf*stream .ds \\*[qrf*name]-xx \\$2
  2311. .        close qrf*stream
  2312. .    \}
  2313. .\}
  2314. ..
  2315. .\"---------------
  2316. .\" get misc-string, output <->42<-> in pass 1
  2317. .\" If two arg -> set var. arg to misc-string.
  2318. .de GETST
  2319. .if \\n[.$]<1 .@error "GETST:reference name missing"
  2320. .if !r qrf*pass .tm "GETST: No .INITR in this file"
  2321. .ds qrf*name qrf*ref-\\$1
  2322. .ie \\n[qrf*pass]=2 \{\
  2323. .    ie !d \\*[qrf*name]-xx .tm "GETHN:\\$1 not defined"
  2324. .    el \{\
  2325. .        ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-xx]
  2326. .        el \\*[\\*[qrf*name]-xx]\c
  2327. .    \}
  2328. .\}
  2329. .\" The answer...
  2330. .el <->42<->\c
  2331. ..
  2332. .\"---------------
  2333. .\" get header-number, output X.X.X. in pass 1
  2334. .\" If two arg -> set var. arg to header-number.
  2335. .de GETHN
  2336. .if \\n[.$]<1 .@error "GETHN:reference name missing"
  2337. .if !r qrf*pass .tm "GETHN: No .INITR in this file"
  2338. .ds qrf*name qrf*ref-\\$1
  2339. .ie \\n[qrf*pass]=2 \{\
  2340. .    ie !d \\*[qrf*name]-hn .tm "GETHN:\\$1 not defined"
  2341. .    el \{\
  2342. .        ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-hn]
  2343. .        el \\*[\\*[qrf*name]-hn]\c
  2344. .    \}
  2345. .\}
  2346. .el X.X.X.\c
  2347. ..
  2348. .\"---------------
  2349. .\" get page-number, output 9999 in pass 1
  2350. .\" If two arg -> set var. arg to page-number.
  2351. .de GETPN
  2352. .if \\n[.$]<1 .@error "GETPN:reference name missing"
  2353. .if !r qrf*pass .tm "GETPN: No .INITR in this file"
  2354. .ds qrf*name qrf*ref-\\$1
  2355. .ie \\n[qrf*pass]=2 \{\
  2356. .    ie !d \\*[qrf*name]-pn .tm "GETPN:\\$1 not defined"
  2357. .    el \{\
  2358. .        ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-pn]
  2359. .        el \\*[\\*[qrf*name]-pn]\c
  2360. .    \}
  2361. .\}
  2362. .el 9999\c
  2363. ..
  2364. .\"----------
  2365. .de GETR
  2366. .if \\n[.$]<1 .@error "GETR:reference name missing"
  2367. .ie !r qrf*pass \{\
  2368. .    tm "GETR: No .INITR in this file"
  2369. .\}
  2370. .el \{\
  2371. .    if \\n[qrf*pass]=2 \{\
  2372. .        GETHN \\$1 Qrfh
  2373. .        GETPN \\$1 Qrfp
  2374. \\*[Qrf]
  2375. .    \}
  2376. .\}
  2377. ..
  2378.